|
|
|
|
|
|
|
|
fd.mkdirs(); |
|
|
fd.mkdirs(); |
|
|
} |
|
|
} |
|
|
//生成excel |
|
|
//生成excel |
|
|
JsonResult result = this.easyExcel(airDataExcelVoList,inspection,fileName,filePath); |
|
|
|
|
|
|
|
|
JsonResult result = this.easyExcel(airDataExcelVoList,inspection,filePath); |
|
|
if (0 != result.getCode()) { |
|
|
if (0 != result.getCode()) { |
|
|
log.info("导出数据业务:生成excel失败:{}", result.getMsg()); |
|
|
log.info("导出数据业务:生成excel失败:{}", result.getMsg()); |
|
|
return result; |
|
|
return result; |
|
|
|
|
|
|
|
|
* @param inspection |
|
|
* @param inspection |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public JsonResult easyExcel(List<AirDataExcelVo> voArrayList,Inspection inspection,String fileName,String filePath) { |
|
|
|
|
|
String filePathName = filePath + fileName; |
|
|
|
|
|
log.info("文件输出目录及格式:filePathName={}",filePathName); |
|
|
|
|
|
|
|
|
public JsonResult easyExcel(List<AirDataExcelVo> voArrayList,Inspection inspection,String filePath) { |
|
|
|
|
|
log.info("文件输出目录及格式:filePathName={}",filePath); |
|
|
List<List<String>> heads = new ArrayList<>(); |
|
|
List<List<String>> heads = new ArrayList<>(); |
|
|
String totalName = "项目名称:"+ inspection.getName(); |
|
|
String totalName = "项目名称:"+ inspection.getName(); |
|
|
String[] nameString = SystemConstant.EXCEL_NAME; |
|
|
String[] nameString = SystemConstant.EXCEL_NAME; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//需要写出的表格(对应实体类) |
|
|
//需要写出的表格(对应实体类) |
|
|
try { |
|
|
try { |
|
|
EasyExcel.write(filePathName, AirDataExcelVo.class).sheet("浓度监测数据").head(heads) |
|
|
|
|
|
|
|
|
EasyExcel.write(filePath, AirDataExcelVo.class).sheet("浓度监测数据").head(heads) |
|
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20)) // 简单的列宽策略,列宽20 |
|
|
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20)) // 简单的列宽策略,列宽20 |
|
|
.doWrite(voArrayList);//数据源 |
|
|
.doWrite(voArrayList);//数据源 |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |