瀏覽代碼

导出数据excel表格

tags/V1.0.1^2
chengwang 1 年之前
父節點
當前提交
df54ccc0fd
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. +4
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/query/QueryAirDataListService.java

+ 4
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airData/query/QueryAirDataListService.java 查看文件

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

Loading…
取消
儲存