Hi All,

I have been facing issues when i generate .xlsx file using SXSSF for the
sheets which have child rows in them. I don't get the data populated in the
particular sheet. I also get the message "excel found unreadable content in
.xlsx. Do you want to recover the contents of this workbook?".

My POI version is 3.8-beta4.

I have written the sample code below. Also, i have attached the excel which
has caused the issue.

It works fine for the sheets generated with normal rows.

    protected void buildExcelDocument(Map<String, Object> model,
SXSSFWorkbook workbook, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

        if (model == null || workbook == null || model.isEmpty()) {
            return;
        }
        String performanceType = (String)
model.get(PerfExcelModelConstants.PERF_TYPE);
        Date effectiveDate = (Date)
model.get(PerfExcelModelConstants.EFF_DATE);
        String entityName = (String)
model.get(PerfExcelModelConstants.ENTITY_NAME);

        String excelSheetName =
CommonUtil.getExcelNameForXssf(performanceType, entityName, effectiveDate);

        response.reset();
        response.setContentType("application/x-download");
        response.setHeader("Content-Disposition", excelSheetName);

           createSampleSheet(model, workbook);
}

    private void createSampleSheet(Map<String, Object> model,
SXSSFWorkbook workbook) {
        Sheet sampleSheet = workbook.createSheet("sampleSheet");

        // Set the sheet outline style
        sampleSheet.setRowSumsBelow(false);

        // Add the as of date
        poiSsUtil.addAsOfDate(sampleSheet, (Date)
model.get(PerfExcelModelConstants.AS_OF_DATE), 0);

        // Get the column inclusion mode
        ColumnInclusionMode columnInclusionMode = (ColumnInclusionMode)
model
            .get(PerfExcelModelConstants.EXCLUSION);

        Map<String, String> columnLabelMapSAmple = new
HashMap<String, String>(COLUMN_LABEL_MAP); // override
              poiSsUtil.addObjListToSheet((List)
model.get(PerfExcelModelConstants.SAMPLE_PERF_LIST), sampleSheet, 1,
            (List<String>)
model.get(PerfExcelModelConstants.SAMPLE_COL_LIST), columnInclusionMode,
            columnLabelMapSample, true);

        // Add freeze pane
        sampleSheet.createFreezePane(1, 3);

        // Auto fit all the columns
        poiSsUtil.autoFitAllColumns(sampleSheet);
    }
http://apache-poi.1045710.n5.nabble.com/file/n4892194/Sample.xlsx
Sample.xlsx 
http://apache-poi.1045710.n5.nabble.com/file/n4892194/Sample.xlsx
Sample.xlsx 

Can somebody please help me out with this issue?

Thanks,
Shreya

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/problem-opening-excel-2007-created-using-SXSSF-with-sheets-having-child-rows-tp4892194p4892194.html
Sent from the POI - User mailing list archive at Nabble.com.

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

Reply via email to