Dear Admins and Community Members ,
As we informed earlier we are trying to Migrate from OOO Calc to LO Calc 
in  our J2EE software.One of the function we need is to " SAVE AS HTML" 
OOO|LO Calc Workbook .Now we are doing it using the code / method below.
ANY CHANCE TO DO IT WITHOUT RUNNING OOO/LO ?(Like POI can do with Excel 
Files.) . We are looking to http://www.jopendocument.org/ , but we are 
very new to LO so any recommendation is very welcome.
Thanks
Nick
public byte[] exportAsHtml(byte[] tempReportContent) {
byte[] htmlContent = null;
try {
log.info <http://log.info>("Exporting As Html");
XStorable xStorable = null;
Object desktop = null;
XComponent document = null;
xRemoteContext = getRemoteContext();
xRemoteServiceManager = xRemoteContext.getServiceManager();
// Get a desktop instance
desktop = 
xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", 
xRemoteContext);
// Get a reference to the desktop interface that can load files
XComponentLoader loader = (XComponentLoader) 
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
XInputStream xStream = new 
ByteArrayToXInputStreamAdapter(tempReportContent);
PropertyValue[] args = new PropertyValue[2];
args[0] = new PropertyValue();
args[0].Name = "InputStream";
args[0].Value = xStream;
args[0].State = PropertyState.DIRECT_VALUE;
args[1] = new PropertyValue();
args[1].Name = "Hidden";
args[1].Value = new Boolean(true);
document = loader.loadComponentFromURL("private:stream", "_blank", 0, args);
ByteArrayOutputStream out = new ByteArrayOutputStream();
XOutputStream xOut = new OutputStreamToXOutputStreamAdapter(out);
PropertyValue[] args1 = new PropertyValue[2];
args1[0] = new PropertyValue();
args1[0].Name = "OutputStream";
args1[0].Value = xOut;
args1[0].State = PropertyState.DIRECT_VALUE;
args1[1] = new PropertyValue();
args1[1].Name = "FilterName";
args1[1].Value = "HTML (StarCalc)";
xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, 
document);
xStorable.storeAsURL("private:stream", args1);
xOut.flush();
htmlContent = out.toByteArray();
xOut.closeOutput();
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return htmlContent;
}
Context
- Save , Save as HTML and  Edit LibreOffice  WorkBook without running LO · libreoffice.ge -AT- gmail.com
 
   
 
  Privacy Policy |
  
Impressum (Legal Info) |
  
Copyright information: Unless otherwise specified, all text and images
  on this website are licensed under the
  
Creative Commons Attribution-Share Alike 3.0 License.
  This does not include the source code of LibreOffice, which is
  licensed under the Mozilla Public License (
MPLv2).
  "LibreOffice" and "The Document Foundation" are
  registered trademarks of their corresponding registered owners or are
  in actual use as trademarks in one or more countries. Their respective
  logos and icons are also subject to international copyright laws. Use
  thereof is explained in our 
trademark policy.