Sorry to say that there is no easy, in-built way to use POI to convert from
one file format to the other. You could however write the code to perform
the conversion; you would need to recover all of the details about each
element of the (HSSF) binary workbook - just for the sake of discussion -
and then create elements in the (XSSF) xml based workbook to mirror them.
If you simply want to perform file conversion, there are other options
including OLE/COM if you are running on a Windows platform, OpenOffice if
you are converting from xml to binary format as I do not think that OO yet
supports writing the Microsoft xml file formats and, finally, there are
on-line conversion 'programs' that you could use but these all carry the
risk of uploading your files to the internet!
Yours
Mark B
Frehmel, Sebastian Rule wrote:
>
> Good morning poi-list!
>
> I am reading an XLS file which will be modified (using POI 3.6).
> How can I write it back to the file system as an XLSX file?
> The thought of it seems easy, yet, I can't find a possibility to do so...
>
> I read the file as follows:
> File inFile = new File("template.xls");
> InputStream bIn = new BufferedInputStream(new FileInputStream(inFile));
> Workbook wb = WorkbookFactory.create(bIn);
>
> [...do something...]
>
> I write as follows:
> File outFile = "out.xlsx";
> BufferedOutputStream bOut = new BufferedOutputStream(new
> FileOutputStream(outFile));
> wb.write(bOut);
>
> Excel then fails loading the document stating that it encountered an
> unexpected file format (The XLSX is probably simply an XLS file)
>
> Thank you!
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://old.nabble.com/Reading-as-XLS%2C-writing-as-XLSX-tp28026334p28031144.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]