java csv 多个sheet_求问 java poi 导出多个sheet页

if("sheet1".equals(sheetname[i])){

Sheet sheet = workbook.createSheet(sheetname[i]);

sheet.setDefaultColumnWidth(15);

Row header = sheet.createRow(0);

CellStyle style = workbook.createCellStyle();

style.setAlignment(CellStyle.ALIGN_CENTER);

Cell cell = header.createCell(0);

cell.setCellStyle(style);

cell.setCellValue("a");

}else if("sheet2".equals(sheetname[i])){

Sheet sheet = workbook.createSheet(sheetname[i]);

sheet.setDefaultColumnWidth(15);

Row header = sheet.createRow(0);

CellStyle style = workbook.createCellStyle();

style.setAlignment(CellStyle.ALIGN_CENTER);

Cell cell = header.createCell(0);

cell.setCellStyle(style);

cell.setCellValue("aa");

}

特意给你测试了一下,这样写是没问题的,仅供参考


版权声明:本文为weixin_31328141原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。