Convert XLS to html using java
Posted: Mon Mar 12, 2012 8:44 pm
I have managed to convert xls to html using OO api in java. However the images are not on the converted html. I would like to store the images in the same way the OO UI application stores the images when I export to html i.e "<img style="height:1.682cm;width:5.4559cm;" alt="" src="data:image/*;base64,iVBORw0KGgoAAAANSUhEUg...."
Below is my code. Please help.
Below is my code. Please help.
Code: Select all
XMultiComponentFactory xMultiComponentFactory = xComponentContext.getServiceManager();
Object desktopService = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xComponentContext);
XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopService);
PropertyValue[] conversionProperties = new PropertyValue[3];
conversionProperties[0] = new PropertyValue();
conversionProperties[1] = new PropertyValue();
conversionProperties[2] = new PropertyValue();
conversionProperties[0].Name = "InputStream";
conversionProperties[0].Value = input;
conversionProperties[1].Name = "Hidden";
conversionProperties[1].Value = new Boolean(true);
conversionProperties[2].Name = "IsExportContentsPage" ;
conversionProperties[2].Value = false;
XComponent document = xComponentLoader.loadComponentFromURL("private:stream", "_blank", 0, conversionProperties);
conversionProperties[0].Name = "OutputStream";
conversionProperties[0].Value = output;
conversionProperties[1].Name = "FilterName";
conversionProperties[1].Value = filterName;
XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class,document);
xstorable.storeToURL("private:stream", conversionProperties);
XCloseable xclosable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,document);
xclosable.close(true);