Bug 21646 - Cannot open large spreadsheet created by POI. Sheet briefly flashes.
Summary: Cannot open large spreadsheet created by POI. Sheet briefly flashes.
Status: RESOLVED DUPLICATE of bug 15375
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-pre3
Hardware: PC All
: P3 major with 6 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-16 11:03 UTC by Jeff
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
Class that simulates the described bug (2.06 KB, text/plain)
2003-07-16 11:04 UTC, Jeff
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff 2003-07-16 11:03:06 UTC
Hello

I have a similar problem as bug 15375 but I can simulate it with very little 
code.


Here is a class that creates two spreadsheets, one good and one bad.


import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**
 * HSSFTest.java
 * 
 * @author mjeffery
 * @created 2003/07/16
 * @version 1a
 */
public class HSSFTest {

  HSSFWorkbook wb = null;
  HSSFSheet sheet = null;
  HSSFRow row = null;
  HSSFCell cell = null;

  public void createSheetThatCanOpen() {
    try {

      wb = new HSSFWorkbook();
      sheet = wb.createSheet();

      for (int i = 0; i < 6000; i++) {

        row = sheet.createRow((short)i);

        cell = row.createCell((short)0);
        cell.setCellValue("Test0");
        cell = row.createCell((short)1);
        cell.setCellValue("Test1");
        cell = row.createCell((short)2);
        cell.setCellValue("Test2");
      }

      FileOutputStream fileOut = new FileOutputStream("c:/warrawarra/good.xls");
      wb.write(fileOut);
      fileOut.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public void createSheetThatCannotOpen() {
    try {

      wb = new HSSFWorkbook();
      sheet = wb.createSheet();

      String tmp1 = null;
      String tmp2 = null;
      String tmp3 = null;

      for (int i = 0; i < 6000; i++) {
        tmp1 = "Test1" + i;
        tmp2 = "Test2" + i;
        tmp3 = "Test3" + i;

        row = sheet.createRow((short)i);

        cell = row.createCell((short)0);
        cell.setCellValue(tmp1);
        cell = row.createCell((short)1);
        cell.setCellValue(tmp2);
        cell = row.createCell((short)2);
        cell.setCellValue(tmp3);
      }

      FileOutputStream fileOut = new FileOutputStream("c:/warrawarra/bad.xls");
      wb.write(fileOut);
      fileOut.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static void main(String[] args) {
    HSSFTest test = new HSSFTest();

    test.createSheetThatCanOpen();
    test.createSheetThatCannotOpen();
  }

}


It seems as if when passing a hardcoded String to the setCellValue method it 
works fine but when passing a variable String it does not correctly create the 
spreadsheet.

The strange thing is when reducing the loop size to 50 in the 
createSheetThatCannotOpen() method, it works fine ?

This problem does not exist in jakarta-poi-1.5.1-final-20020615.

Any help will be appreciated.
Comment 1 Jeff 2003-07-16 11:04:32 UTC
Created attachment 7327 [details]
Class that simulates the described bug
Comment 2 Andy Oliver 2003-07-24 17:13:23 UTC
we should fix this.
Comment 3 Jeff 2003-07-28 11:15:41 UTC
I have noticed that (In my case) as soon as the SST table becomes very big this 
happens.

I can put thousands of strings into a spreadsheet as long as there are not too 
many unique ones. As soon as there are plenty unique strings the sheet can't 
open.

Using the BIFF Viewer, I see that CONTINUE RECORD's are written for the 
spreadsheet that can't open and none are written for a spreadsheet that can 
open.

From looking at the source (I am not sure though) it seems that these CONTINUE 
RECORDs are a major change between POI 1.5.1 and POI2.

Am I on the wrong track ???
Comment 4 sanjay 2003-07-28 20:10:40 UTC
Hello 
 I have a similiar problem while populating the excel sheet. if the rows are
more then 3000(Apprx 640kb). then i am not able to open the excel file. It just
flash. 
Else it is ok. Iam populating the excel sheet from database. 
I can see the size of the downloaded file eg: 900kb.

Let me know if you have any resolution for this. Or any planned fix for the bug.

Do you think the size may be the problem.

thanks
Sanjay 
Comment 5 Avik Sengupta 2003-10-06 09:51:37 UTC
This is the same as bug 15375. The testcase here has been attached to 15375 as
well. Marking this invalid, please track 15375 (not marking this as duplicate
since the mailing list on 15375 is already more than 10 people, dont want to
spam them further!!)
Comment 6 Avik Sengupta 2003-10-07 15:57:37 UTC
Will mark this as duplicate to ensure correct records for future use!
Comment 7 Avik Sengupta 2003-10-07 15:58:02 UTC

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