We create Excel workbooks dynamically in memory based on the business rules in our application and then dump the excel workbook onto the disk. When we try to open using Microsoft Excel, we get the error: “File error: data may have been lost”. I have attached one of the workbooks for your reference.
We are not able to replicate this error if we create a workbook using a sample program. Can you please let us know the problem in the attached workbook that is causing the error to come up in MS Excel?
Also thanks for giving the event based parsing API on time. It works fine and is fast. Just one feedback though… When we change the file format to MS Excel 2007 all the operations are slow i.e. create, fill and event parser API.
Thank you for your file. It is because the cells in the workbook exceeds the 256 column limit of Excel2003 file format. We will release a new version in few days, which will cut out such exceeding cells automatically when save workbook in Excel2003 file format.
For the performance of Excel 2007 file, it is mainly because the file format, Excel2007 save file as compressed xml format, the uncompress and parsing xml file will cause more time cost than common binary data of Excel2003 file.
Thanks for the reply. I tried running the below code snippet on the workbook that I uploaded. After doing so, I found out that the maxColumn was showing up as 255. I used the checkCell API to see if there is any cell defined at that column. I could not find one. I have omitted some code for brevity. I feel there is something being written to the workbook while save. Can you please check on your side?
Worksheets worksheets = workbook.getWorksheets();
Worksheet worksheet = workbook.getWorksheets().getSheet(“RDN136”);
int maxRow = worksheet.getCells().getMaxRow();
int maxCol = worksheet.getCells().getMaxColumn();
//The below line shows up maxCoulmn as 255.
System.out.println(“Max Row: [” + maxRow + “] maxColumn: [” + maxCol + “]” );
for(int row=0 ; row < maxRow; row++)
for(int column=0; column < maxCol; column++)
Cell cell = worksheet.getCells().checkCell(row,column);
if(cell!= null )
System.out.println(“Column Index: [” + column + “] Row Index: [” + row + “] Name: [” + cell.getName() + “] [” + cell.getValue() + “]”);
Yes, there has no defined cell in those columns. However, there did has defined Column at column 255, I think maybe you have called some API such as Cells.getColumn(int) before save the workbook, that cause such Column be created. For your case, I think you can use Cells.getMaxDataColumn() in place of getMaxColumn() to get the max column which be defined and not empty.