public String expData() throws Exception{
        
    List<SubArea> list = subAreaService.findAll();
    
    HSSFWorkbook hssf = new HSSFWorkbook();
    HSSFSheet sheet = hssf.createSheet("分页信息");
    HSSFRow titleRow = sheet.createRow(0);
        
    titleRow.createCell(0).setCellValue("分区编号");
    titleRow.createCell(1).setCellValue("所属省份");
    titleRow.createCell(2).setCellValue("所属城市");
    titleRow.createCell(3).setCellValue("所属区域");
    for (SubArea subArea: list) {
        HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
        dataRow.createCell(0).setCellValue(subArea.getId());
        dataRow.createCell(1).setCellValue(subArea.getArea().getProvince());
        dataRow.createCell(2).setCellValue(subArea.getArea().getCity());
        dataRow.createCell(3).setCellValue(subArea.getArea().getDistrict());
    }
    ServletOutputStream out = ServletActionContext.getResponse().getOutputStream();
    ServletActionContext.getResponse().setContentType("application/vnd.ms-excel");
    String fileName = "分区数据.xls";
    String agent = ServletActionContext.getRequest().getHeader("User-Agent");
    fileName =     FileUtils.encodeDownloadFilename(fileName, agent);
        ServletActionContext.getResponse().setHeader("content-disposition", "attachment;filename="+fileName );
        hssf.write(out);
        return NONE;
    }

 

相关文章:

  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-08-31
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-01-21
相关资源
相似解决方案