public void excelExport(HttpServletResponse response, List<PutAssetsProject> result) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
try {
SXSSFWorkbook workbook = new SXSSFWorkbook();
Sheet sheet = workbook.createSheet("项目报表");
Row rowTitle = sheet.createRow(0);
Cell cellTitle = null;
cellTitle = rowTitle.createCell(0);
cellTitle.setCellValue("序号");
cellTitle = rowTitle.createCell(1);
cellTitle.setCellValue("项目编号");
cellTitle = rowTitle.createCell(2);
cellTitle.setCellValue("项目名称");
cellTitle = rowTitle.createCell(3);
cellTitle.setCellValue("项目描述");
cellTitle = rowTitle.createCell(4);
cellTitle.setCellValue("创建人");
for (int i = 0; i < result.size(); i++) {
Row row = sheet.createRow(i + 1);
Cell cell = null;
cell = row.createCell(0);
cell.setCellValue(i + 1);
cell = row.createCell(1);
cell.setCellValue(result.get(i).getProjectCode());
cell = row.createCell(2);
cell.setCellValue(result.get(i).getProjectName());
cell = row.createCell(3);
cell.setCellValue(result.get(i).getDescription());
cell = row.createCell(4);
cell.setCellValue(result.get(i).getCreateUser());
cell = row.createCell(5);
cell.setCellValue(status(result.get(i).getStatus()));
cell = row.createCell(6);
cell.setCellValue(result.get(i).getStartTime());
}
OutputStream output=response.getOutputStream();
response.reset();
final String name = new String("项目报表".getBytes("UTF-8"), "ISO8859-1");
response.setContentType("application/msexcel");
response.setHeader("Content-Disposition","attachment;filename="+ name +".xlsx");
workbook.write(output);
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}