| Author |
MS Excel error while opening xls generated using poi jar
|
Hari Gundappa
Greenhorn
Joined: Sep 13, 2011
Posts: 27
|
|
Hi,
I am using the latest stable version of apache poi jars to create xls files using a servlet.
I am able to save the xls to the disk . Howeve when I try to open this file xls crashes and comes up with error report. Next Excel autorepairs the document and opens the sheet which does not have any format
i created. The data is intact though.
Can some one please help with this?
Thanks,
Hari
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
|
All we know at this point is that you, with the help of the Apache POI package, produced a malformed Excel file. We would need much more detail to be able to help.
|
 |
Hari Gundappa
Greenhorn
Joined: Sep 13, 2011
Posts: 27
|
|
Hi Paul,
Sorry for the abrupt info.
I am using poi 3.7 to create a very simple excel sheet with just one row of data.
I am able to stream the response back to client and its being saved to disk . When I open that file excel crashes.
Here;s my code like
My code is as simple as above I aslo use the same code to write 2 more rows with same values.
Please let me know if I missing something.
Thanks,
Hari
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
|
If that's the sort of code we're talking about, then it would be a good idea if you could produce an SSCCE which exhibits your problem. (Follow the link, read the document it leads to.) The code you posted is not enough for us to work with because it doesn't show how you write the data to the file. But it shouldn't be hard for you to expand it to an SSCCE which we can work with.
|
 |
Hari Gundappa
Greenhorn
Joined: Sep 13, 2011
Posts: 27
|
|
Hi Paul,
The error was due to the way I was streaming the output.
I was coinverting the HSSFWorkbook output as bytes using its getBytes() method which was causing some data format and encoding to be lost.
Then instead I wrote the workbook object directly to the servlet stream as
This fixed it.
Thanks for the inputs.
Hari
|
 |
 |
|
|
subject: MS Excel error while opening xls generated using poi jar
|
|
|