https://issues.apache.org/bugzilla/show_bug.cgi?id=53650

          Priority: P2
            Bug ID: 53650
          Assignee: [email protected]
           Summary: SXSSF can be made to output corrupt XLSX files
          Severity: normal
    Classification: Unclassified
                OS: Linux
          Reporter: [email protected]
          Hardware: PC
            Status: NEW
           Version: unspecified
         Component: SXSSF
           Product: POI

Created attachment 29162
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29162&action=edit
Spreadsheet which SXSSF cannot process

I am attempting to use SXSSF to add data to a template XLSX file.  I have a
XLSX file produced by Excel for Mac 2011 version 14.2.3, which when processed
with the attached minimal Java produces a file which does not open in Excel,
but does open in Open Office.  Excel reports the file as broken and offer
repair, which removes all the additions placed in by the Java code.

I am using POI 3.8. XSSF is able to process the file correctly.

Minimal Java below,

package sheet2test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

/**
 *
 * @author davel
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            final Workbook wb = new SXSSFWorkbook(new XSSFWorkbook(new
FileInputStream("template.xlsx")));

            Sheet currentSheet = wb.getSheetAt(1);

            Row currentRow = currentSheet.createRow(1);
            Cell currentCell = currentRow.createCell(1);
            currentCell.setCellType(Cell.CELL_TYPE_STRING);
            currentCell.setCellValue("hello world!");

            FileOutputStream out = new FileOutputStream("broken.xlsx");
            wb.write(out);
        }
        catch (IOException e) {
            System.err.println("Could not write output file");
        }
    }

}


Kind regards,
Dave Lambley

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to