https://issues.apache.org/bugzilla/show_bug.cgi?id=57288
Simon Tan <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW --- Comment #4 from Simon Tan <[email protected]> --- 1. Below is the code, attach is before and after this code do SaveAs to pdf's result. public static void generateReport( String reportFile, List<ExampleVO> voList) { InputStream in = null; FileOutputStream out = null; try { in = Report.class.getResourceAsStream("/template.xls"); Workbook workbook = WorkbookFactory.create(in); Sheet sheet = workbook.getSheetAt(0); int rowNum ; if (null != voList) { rowNum = 12; int sn = 1; for (ExampleVO vo : voList) { int colNum = 2; row = sheet.createRow(rowNum++); row.createCell(colNum++).setCellValue(sn++); row.createCell(colNum++).setCellValue(vo.getAt()); // replace value to same for security row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); row.createCell(colNum++).setCellValue(vo.getAt()); } CellStyle cellStyle = workbook.createCellStyle(); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderTop(CellStyle.BORDER_THIN); cellStyle.setBorderRight(CellStyle.BORDER_THIN); for(int i = 12; i< rowNum; i++){ for(int j = 1; j< 16; j++){ Cell cell = sheet.getRow(i).getCell(j); if(null==cell){ cell = sheet.getRow(i).createCell(j); } cell.setCellStyle(cellStyle); } } } File f = new File(reportFile); FileUtil.createFile(f); out = new FileOutputStream(f); //workbook.setPrintArea(0, "$A$1:$Q$" + rowNum); logger.info(row.getLastCellNum()+""); workbook.write(out); out.close(); in.close(); } catch (FileNotFoundException e) { logger.error("File XXX Not Found!", e); } catch (IOException e) { logger.error(e.getMessage(), e); } catch (InvalidFormatException e) { logger.error("Template report file XXX invalid format", e); } } -- 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]
