@PostMapping("/exportAge")
@ApiOperation("导出信息")
public void exportAge(HttpServletResponse response , @RequestBody PopulationStatisticsQuery query) throws IOException {
list<PopulationStatisticsVo> list = this.statisticsAges(query.getImportYear());
String templateName = "各年龄段类型分布.xlsx";
InputStream template = this.getClass().getClassLoader().getResourceAsStream("template/" + templateName);
OutputStream outputStream = response.getOutputStream();
Workbook workbook = new XSSFWorkbook( template );
Sheet sheet = workbook.getSheet("各年龄段类型分布");
for (int i = 0; i < list.size(); i++) {
Row dataRow = sheet.getRow(i+2);
dataRow.createCell(0).setCellValue(i+1);
dataRow.createCell(1).setCellValue(list.get(i).getAges());
dataRow.createCell(2).setCellValue(list.get(i).getPopCount());
dataRow.createCell(3).setCellValue(list.get(i).getRatio());
dataRow.createCell(4).setCellValue(list.get(i).getReportYear());
}
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
}