Hmm, looks like the attachment didn't get through in my previous e-mail, so
I'm including the code inline.

============================================================================
====
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

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;


public final class HssfTest {
        public static final void main(final String[] args) throws IOException {
                final HSSFWorkbook wb = new HSSFWorkbook();
                final HSSFSheet sheet = wb.createSheet();
                for (int i = 0; i < 30000; i++) {
                        final HSSFRow row = sheet.createRow(i);
                        final HSSFCell cell = row.createCell((short) 0);
                        cell.setCellValue(Integer.toString(99999999 - i));
                }
                final OutputStream out = new FileOutputStream(new 
File("C:\\test.xls"));
                try {
                        wb.write(out);
                } finally {
                        out.close();
                }
        }
}
============================================================================
====


-----Original Message-----
From: Robert Lowe [mailto:[EMAIL PROTECTED]
Sent: Friday, October 03, 2003 9:47 PM
To: [EMAIL PROTECTED]
Subject: Excel cannot open HSSF file with 30,000 rows generated by POI
2.0 pre-release 3


Hi,

I'm having problems generating an HSSF file with around 30,000 rows using
the 2.0 pre-release 3.

Initially I encountered OutOfMemory errors, however after increasing the JVM
heap size the program that generates the file appeared to run correctly.
However, Excel 2000 cannot open the output file produced. (There's no error
message--the document window just flashes up on the screen for a split
second before disappearing.)

I managed to produce a simple test case that demonstrates the problem--see
HssfTest.java. (If anyone's interested I can send you the output file
generated, but I don't want to send it to the list as it's about 1.3 MB.)

This problem does not occur on the latest stable release version, 1.5.1.

Any workarounds would be greatly appreciated! (I can't go back to 1.5.1
because I need the cloneSheet() method... :-( )

Best regards,

Robert Lowe
http://RMLowe.com/




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to