java execl导出 SXSSFWorkbook
public void test(List<Map<String, String>> cellcytokinesInfoMaps,String title) throws IOException {
String path = meituoExcelPatch + title + ".xlsx";
File file_excel = new File(path);
if (file_excel.exists()) {
file_excel.delete();
}
File inputFile = new File(path);
FileOutputStream output = new FileOutputStream(path);
if (inputFile.exists()) {
try {
SXSSFWorkbook wb = new SXSSFWorkbook(500);
Sheet sheet1 = wb.createSheet();
Row row_head= sheet1.createRow(0);
row_head.createCell(0).setCellValue("id");
row_head.createCell(1).setCellValue("name");
row_head.createCell(2).setCellValue("age");
for (int i = 0; i < cellcytokinesInfoMaps.size(); i++) {
Map<String, String> stringStringMap = cellcytokinesInfoMaps.get(i);
int row_num = i + 1;
Row row_info = sheet1.createRow(row_num);
row_info.createCell(0).setCellValue(stringStringMap.get("id"));
row_info.createCell(1).setCellValue(stringStringMap.get("name"));
row_info.createCell(2).setCellValue(stringStringMap.get("age"));
}
wb.write(output);
output.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
output.close();
}
}
}