I am getting "Excel has unreadable content Error" When creating excel using SXSSF API. Below are the jars that i am using: poi-3.9 poi-ooxml-3.9.jar poi-ooxml-schemas-3.9.jar xmlbeans-2.4.0.jar
public class CarveOutReportXLSFileDownload extends AbstractXlsxStreamingView { protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request, HttpServletResponse response) throws WalgreensException { final String PAGENAME = "report.carveList"; DashboardSummaryResponseBean responseBean = (DashboardSummaryResponseBean)model.get("data"); try { String filename = ApplicationConstants.REPORT_CARVE_OUT_FILENAME + DateFormatter.format( ApplicationConstants.ADHOC_FILE_DATE, new Date()) + ".xlsx"; String reportRuntime = DateFormatter.format("MM/dd/yyyy hh:mm a", new Date()); workbook = new SXSSFWorkbook(1000); DataFormat dataformat = workbook.createDataFormat(); CellStyle dataStyle = workbook.createCellStyle(); dataStyle.setDataFormat(dataformat.getFormat("text")); dataStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); dataStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); dataStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); dataStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); dataStyle.setAlignment(CellStyle.ALIGN_CENTER); carveOutSheet.setColumnWidth(0, 120 * 25); carveOutSheet.setColumnWidth(1, 120 * 25); carveOutSheet.setColumnWidth(2, 200 * 25); carveOutSheet.createFreezePane(0, 9); int rowCnt = 9; if (responseBean.getMedicaidCarveOutList() != null && responseBean.getMedicaidCarveOutList().size() != 0) { for (MedicaidReportingBean bean : responseBean .getMedicaidCarveOutList()) { row = carveOutSheet.createRow(rowCnt); colIdx = 0; row.createCell(colIdx).setCellValue( new HSSFRichTextString(bean.getBin())); row.getCell(colIdx).setCellStyle(dataStyle); colIdx++; row.createCell(colIdx).setCellValue( new HSSFRichTextString(bean.getPcn())); row.getCell(colIdx).setCellStyle(dataStyle); colIdx++; row.createCell(colIdx).setCellValue( new HSSFRichTextString(bean.getGroupId())); row.getCell(colIdx).setCellStyle(dataStyle); colIdx++; rowCnt++; } } else { row = carveOutSheet.createRow(rowCnt); row.createCell(0).setCellValue( new HSSFRichTextString(Language.getText(PAGENAME, "noRecordFound"))); CellRangeAddress cellRangeAddress = new CellRangeAddress( rowCnt, rowCnt, 0, 2); carveOutSheet.addMergedRegion(cellRangeAddress); RegionUtil.setBorderTop(CellStyle.BORDER_NONE, cellRangeAddress, carveOutSheet, workbook); RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, cellRangeAddress, carveOutSheet, workbook); RegionUtil.setBorderRight(CellStyle.BORDER_THIN, cellRangeAddress, carveOutSheet, workbook); RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, cellRangeAddress, carveOutSheet, workbook); } response.setContentType("application/vnd.ms-excel"); response.setHeader("content-disposition", "attachment; filename=" + filename); OutputStream os = response.getOutputStream(); workbook.write(os); os.flush(); os.close(); } catch (Exception ex) { ex.printStackTrace(); //return false; } logger.debug("in CarveOutReportXLSFileDownload.execute(): END"); //return true; } /*@Override protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO Auto-generated method stub }*/ } -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Excel-has-unreadable-content-Error-When-creating-excel-using-SXSSF-API-tp5726456.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org