我在表格中列出了员工记录,我希望生成报告。有没有办法生成 excel格式生成的报告并将其发送回浏览器。我正在使用 Spring boot 和 reactjs
答案 0 :(得分:0)
您可能希望查看Apache POI
有一些在developers guide
中创建XLS [X]文件的示例那里的一个简单例子
Workbook wb = new HSSFWorkbook();
//Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
// Write the output to a file
try (OutputStream fileOut = new FileOutputStream("workbook.xls")) {
wb.write(fileOut);
}