poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Hirschi" <ohirs...@pm-medici.ch>
Subject filesize of opened and saved xls with POI
Date Mon, 18 Apr 2005 14:53:39 GMT

I am using POI 2.5.1 with a excel-2002 file.

The goal is to open a given xls-file and export a resultset into a give
sheet in the workbook. The sheet should clear before write the new data
to the sheet.

I have solved the problem as followed:
    String sSheetName = "AdFS2";

    int k = 1;

    try {

      POIFSFileSystem fs = new POIFSFileSystem(new
      HSSFWorkbook wb = new HSSFWorkbook(fs);
      HSSFSheet sheet = wb.getSheet(sSheetName);

      for(int i=0; i<=sheet.getLastRowNum(); i++) {
        HSSFRow row = sheet.getRow(i);
        if(row != null) sheet.removeRow(row);

      if(sheet != null) {
        for(int i=0; i<500; i++) {
          HSSFRow row = sheet.getRow(i);
          if(row == null) row = sheet.createRow(i);
          for(int j=0; j<20; j++) {
            HSSFCell cell = row.getCell((short)j);
            if (cell == null) cell = row.createCell((short)j);
            cell.setCellValue(k+" "+i+""+j);

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    } catch(FileNotFoundException fnfe) {
    } catch(IOException ioe) {

The problem is, that the xls- file is increasing the size on every save,
even I only increase "k"!
If I save the xls everytime with another name, the size is ever the

- I think the history is also ever stored in the xls? Is it right?
- Is there a way to prevent this?
- Or have I done something else not the right way?

Thanks in advance for all your help!
Oliver Hirschi

To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

View raw message