java poi 在向excel 列名为AA 插入值时,插入不进去,也不报任何错
try (ServletOutputStream outputStream = response.getOutputStream()) {
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
FileInputStream fileInputStream = new FileInputStream(path+"/export_temp/XXXX.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
Sheet sheet = workbook.getSheetAt(0);
for (int i = 4; i < 10; i++) {
Row row = sheet.createRow(i);
Cell cell = row.createCell(0);
cell.setCellValue("XXX");
Cell cell1 = row.createCell(1);
Cell cell2 = row.createCell(2);
Cell cell3 = row.createCell(3);
Cell cell4 = row.createCell(4);
Cell cell5 = row.createCell(5);
cell5.setCellValue("XXXX");
}
SimpleDateFormat sdf = new SimpleDateFormat("_yyyyMMdd");
String fileName = "XXXX_" + sdf.format(new Date()) + ".xlsx";
String encode = URLEncoder.encode(fileName, "UTF-8");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment;filename=" + encode);
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}