简体   繁体   中英

JAVA Apache poi Excel corrupt

I am using Apache poi library in java for generating excel report.

For generating excel report, i am reading text file which is delimited using PIPE and writing that into excel sheet.

Most of the cases say 98%, i don't see any issue. Some times the excel file generated unable to open. Says "Unreadable content".

I am fixing the issue by adding /removing one or two character(ie XX or AA) to/from the data in the text file resolves this issue. I have compared data file of working one as well as corrupted one. I don't see any difference at all.

I am not sure what could be the reason for this issue. I don't see any exception or error while writing data in to excel file.

Datafile is thousands of lines and the source code has around 15 classes each goes around 300 to 400 lines. So, it's hard to post both. Sharing partial feed or class is not worth since the any addition/removal of character makes the sheet readable

This excel report has 10 to 15 sheets and multiple formats and cell merge as well as formula.

Does anyone have suggestion on this. Is there chance for memory issue while reading or writing. File is read line by line and written as sheet by sheet.

I went through the whole application and i could not find any trace. So i upgraded the application from Apache poi HSSF to Apache poi XSSF and refactored all the methods in the application that fixed this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM