• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MS Excel error while opening xls generated using poi jar

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic