I did some additional testing and it appears that when I call "sheet.removeRow(row);",
it clears out the row contents, but doesn't actually remove the row. So, I basically
have a spreadsheet with 2800 blank rows eating up file space. Is there anyway to
actually REMOVE REMOVE the row?
-----Original Message-----
From: Jean, Victor [IT]
Sent: Thursday, May 20, 2004 9:15 PM
To: POI Users List
Subject: HELP!! Bug with Output File Size!!!
I'm running into a bug with the file size of the outputfile.
I have a template excel file that's about 1 megabyte in size of just plain unformatted
data on sheet one.
I'm reading this file in and then removing all the rows from sheet one and writing to
a output file.
The output file size is listed as 500K, but it has NO data at all. It is completely
empty.
When I go ahead and click the "Save" button in excel and close the spreadsheet, the
size shrinks to 14K.
Is this a bug or am i doing something wrong?
Why is the output file size so big even though there's no data at all ?
___________________My Code Start____________________
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("c:/bigfile.xls"));
HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs);
HSSFSheet sheet = hssfworkbook.getSheetAt(0);
// Create outputstream for excel file
FileOutputStream stream = new FileOutputStream("c:/smallfile.xls");
int numberRows = sheet.getLastRowNum()+1;
for (int k = 0; k < numberRows; k++)
{
HSSFRow row = sheet.getRow(k);
if (row != null) {
sheet.removeRow(row);
}
}
hssfworkbook.write(stream);
stream.close();
___________________My Code End______________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]