Hello. My POI-Version: poi-bin-3.0.1-FINAL-20070705.zip I've generated XLS-File with: try { HSSFWorkbook wb = new HSSFWorkbook(); HSSFCellStyle styleDate = wb.createCellStyle(); styleDate.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); if (result != null) { // create a new sheet HSSFSheet s = wb.createSheet(); // declare a row object reference HSSFRow r = null; // declare a cell object reference HSSFCell c = null; wb.setSheetName(0, "RemovalInstallationList"); // first row with headings r = s.createRow(0); c = r.createCell((short) 0); c.setCellValue(new HSSFRichTextString("Three Letter Code")); .... c = r.createCell((short) 37); c.setCellValue(new HSSFRichTextString("Description")); s.setColumnWidth((short) (0), (short) ((50 * 4) / ((double) 1 / 20))); .... s.setColumnWidth((short) (37), (short) ((50 * 4) / ((double) 1 / 20))); Iterator it = result.iterator(); for (int i = 0; it.hasNext(); i++) { RemovalInstallationReportResultRowModel resultModel = null; resultModel = (RemovalInstallationReportResultRowModel) it.next(); // create a row with data r = s.createRow(i + 1); c = r.createCell((short) 0); if (resultModel.getThreeLC() != null) { c.setCellValue(new HSSFRichTextString(resultModel.getThreeLC())); } else { c.setCellValue(new HSSFRichTextString("")); } .... c = r.createCell((short) 37); if (resultModel.getDescriptionPartNoInstalledComponent() != null) { c.setCellValue(new HSSFRichTextString(resultModel.getDescriptionPartNoInstalledComponent())); } else { c.setCellValue(new HSSFRichTextString("")); } } return new RemovalInstallationReportCSVModel(Status.OK, wb.getBytes()); } calling method: byte[] resultAsByte = csvModel.getTransferObject(); if (result != null) { inputStream = new ByteArrayInputStream(resultAsByte); } input(); return "exportCSV"; Struts-Config.xml <result name="exportCSV" type="stream"> <param name="contentType">application/vnd.ms-excel</param> <param name="inputName">inputStream</param> <param name="contentDisposition">filename="document.xls"</param> </result> The result is a message from Excel during opening the file like: Microsoft Excel Datei-Reparatur Protokoll In Datei 'D:\tmp\exported_file_damaged_231107.xls' wurden Fehler festgestellt Die folgenden Reparaturen wurden durchgeführt: Die Zusammenfassungs-Information des Dokumentes ist verloren gegangen. The resulting exported file is attached. Kind regards.
Created attachment 21177 [details] corrupted damaged XLS file
You are not supposed to call workbook.getBytes() directly. This method is used to construct the Workbook node in the document file system. Change the following line return new RemovalInstallationReportCSVModel(Status.OK, wb.getBytes()); to ByteArrayOutputStream out = new ByteArrayOutputStream(); wb.write(out); return new RemovalInstallationReportCSVModel(Status.OK, out.toByteArray()); It should work. Yegor
@Yegor: Thank you very much, it work's now. Best regards & a nice weekend.