Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

MS Excel error while opening xls generated using poi jar

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!