@RequestMapping("/export/score")
public void exportClassScore(HttpServletRequest request, HttpServletResponse response) throws IOException {
ServletOutputStream out = response.getOutputStream();
String fileName = "导入模版.xls";
response.setHeader("Content-Disposition", "attachment;filename="+ new String(fileName.getBytes(),"ISO-8859-1"));
examPaperService.exportClassScore(out);
}
@Override
public void exportClassScore(ServletOutputStream out) {
HSSFWorkbook book = new HSSFWorkbook();
String sheetName = "导入模版";
HSSFSheet sheet = book.createSheet(sheetName);
HSSFRow row_1 = sheet.createRow(0);
row_1.createCell(0).setCellValue("");
row_1.createCell(1).setCellValue("最高气温");
row_1.createCell(2).setCellValue("最低气温");
row_1.createCell(3).setCellValue("平均气温");
HSSFRow row_2 = sheet.createRow(1);
row_2.createCell(0).setCellValue("周一");
row_2.createCell(1).setCellValue("12.0");
row_2.createCell(2).setCellValue("23.0");
row_2.createCell(3).setCellValue("10.0");
HSSFRow row_3 = sheet.createRow(2);
row_3.createCell(0).setCellValue("周二");
row_3.createCell(1).setCellValue("11.0");
row_3.createCell(2).setCellValue("24.0");
row_3.createCell(3).setCellValue("9.0");
HSSFRow row_4 = sheet.createRow(3);
row_4.createCell(0).setCellValue("周三");
row_4.createCell(1).setCellValue("12.5");
row_4.createCell(2).setCellValue("22.0");
row_4.createCell(3).setCellValue("11.0");
HSSFRow row_5 = sheet.createRow(4);
row_5.createCell(0).setCellValue("周四");
row_5.createCell(1).setCellValue("13.5");
row_5.createCell(2).setCellValue("20.0");
row_5.createCell(3).setCellValue("12.0");
HSSFRow row_6 = sheet.createRow(5);
row_6.createCell(0).setCellValue("周五");
row_6.createCell(1).setCellValue("16.0");
row_6.createCell(2).setCellValue("24.0");
row_6.createCell(3).setCellValue("12.0");
try {
book.write(out);
book.close();
} catch (IOException e) {
e.printStackTrace();
}
}
还没有评论,来说两句吧...