You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/07/16 13:03:07 UTC

DO NOT REPLY [Bug 21646] New: - Cannot open large spreadsheet created by POI. Sheet briefly flashes.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21646>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21646

Cannot open large spreadsheet created by POI. Sheet briefly flashes.

           Summary: Cannot open large spreadsheet created by POI. Sheet
                    briefly flashes.
           Product: POI
           Version: 2.0-dev
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: dandare100@yahoo.com


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.