Reading and Writing Excel Files with POI
Subject:   File increase size problem
Date:   2007-05-29 06:43:17
From:   jagjit
Hi ,m writing in excel sheet using POI as well as jexcelfile..........everytime the file size doubles..if the template i use to write is of 2 mb.then the output file size becomes 4 mb.........can sm1 help me on this?
Main Topics Oldest First

Showing messages 1 through 2 of 2.

  • File increase size problem
    2007-08-31 00:11:30  Subhash1027 [View]

    Hi Jagjit,
    I am also facing the same problem. Also when the open the file(double sized file), it is getting opened in repaired mode. Did you find any fix for this? If so, please let me know.
    Thanks in advance.

    Thanks & Regards,
  • File increase size problem
    2007-08-17 04:59:15  raj7711 [View]


    Greetings!! I am using Apache POI package for a Java application to read and write excel files. I am facing one specific problem.

    I have a excel template which contains complex macros, images and complex formatting. I used HSSFWorkbook to read the input template file and filled in data in the template, and created the output file using FileOutputStream. The output file is created with all the required data and the formatting remains same and the output file looks just like the template file with all formatting and the required data. But the problem is, my input template file size is 831KB. But the output file size is 1919KB. The output file size is getting doubled. Is there any solution to fix this issue?

    Another thing I tried is, If I open the bigger output file (1919KB) in MS-Excel and saved the file manually, then the file size reduces to normal size (850KB). I couldn't understand why the size increased tremendously if the file contains macros.

    I have given the code below:

    HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(templateFileName), true);

    HSSFSheet sheet = wb.getSheet("Adjustment Request");

    HSSFRow row = sheet.getRow(10);
    HSSFCell cell = row.getCell((short)3);

    if (cell == null) {
    cell = row.createCell((short)3);

    cell.setCellValue("This is test");
    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream(destFileName);

    Thanks and Regards,