Bug 24355

Summary: Cannot create sheet with over 8215 datapoints
Product: POI Reporter: Dan Shinton <daniel.shinton>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: critical    
Priority: P3    
Version: 2.0-pre3   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Dan Shinton 2003-11-03 14:16:25 UTC
This bug is present on both Win32 and Solaris Sparc.

When trying to create a spreadsheet with over 8215 datapoints, the resultant 
xls file becomes corrupt. Excel attempts to repair the document, but some of 
the data at the end of the file is lost. The following are the maximum sizes of 
spreadsheets I could create w/o corruption:

8215 rows, 1 column
4107 rows, 2 columns
2738 rows, 3 columns

I am using JDK 1.4.2. I am using Excel 2002 SP-2.

The following is the code I used to produce the problem:

    public void createFile(String filename, int height, short width) throws 
Exception {
        FileOutputStream fileOut = new FileOutputStream(filename);
        
        HSSFWorkbook wb;
        HSSFSheet sheet;
        HSSFRow row;
        HSSFCell cell;
        
        int counter = 0;
        
        wb = new HSSFWorkbook();
        sheet = wb.createSheet("Test sheet");
        
        for (int i = 0; i < height; ++i) {
            row = sheet.createRow(i);
                       
            for (short s = 0; s < width; ++s) {
                ++counter;
                
                cell = row.createCell(s);
                cell.setCellValue(String.valueOf(counter));
            }
        }
        
        wb.write(fileOut);
        fileOut.close();        
    }
Comment 1 Avik Sengupta 2003-11-03 17:54:20 UTC
This has been fixed in 2.0RC1. But thanks for a pretty well researched bug report!

*** This bug has been marked as a duplicate of 15375 ***