public static void exportExcel(ListdataList, String filename, OutputStream out){/*try {
//读取模板
InputStream in = new FileInputStream("C:\\Users\\yinbx\\IdeaProjects\\JCogent\\cogent-common\\src\\main\\java\\com\\cogent\\template\\cure_plans.xls");
//通过模板创建工作簿
HSSFWorkbook wb = new HSSFWorkbook(in);
//获取shell
HSSFSheet sheet = wb.getSheetAt(0);
//获取模板的内容
HSSFRow Trow = sheet.getRow(2);
int i=3;
HSSFRow row = null;
HSSFCell cell = null;
for (Map map: dataList) {//遍历数据集填充到excel
row = sheet.createRow(i);
for(int j=0; j
cell = row.createCell((short)j);
//cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(map.get(Trow.getCell(j).getStringCellValue()).toString());
}
i++;
}
wb.write(out);
out.close();
}catch (IOException e){
System.out.println("文件流异常");
e.printStackTrace();
}*/
try{
WorkbookSettings settings= newWorkbookSettings();
settings.setWriteAccess(null);
settings.setEncoding("UTF-8");
Workbook wb= Workbook.getWorkbook(new File("C:\\Users\\yinbx\\IdeaProjects\\JCogent\\cogent-common\\src\\main\\java\\com\\cogent\\template\\cure_plans.xls"));
WritableWorkbook wwb=Workbook.createWorkbook(out, wb,settings);
WritableSheet sheet= wwb.getSheet(0);int i =3;
Label label;for(Map map : dataList){for(int j =0; j
label=new Label(j,i,map.get(sheet.getCell(j,2).getContents()).toString());
sheet.addCell(label);
}
i++;
}
wwb.write();
wwb.close();
}catch(IOException e) {
e.printStackTrace();
}catch(BiffException e) {
e.printStackTrace();
}catch(RowsExceededException e) {
e.printStackTrace();
}catch(WriteException e) {
e.printStackTrace();
}
}