diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java index 48b64ed..df43d2c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java @@ -10,6 +10,7 @@ import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainReportExcel; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.utils.ExcelMergeHandler; +import com.hnac.hzims.operational.duty.utils.ExcelTool; import com.hnac.hzims.operational.duty.vo.ChangeDutyMainVo; import com.hnac.hzims.operational.duty.vo.HomePageDutyMainInfoVo; import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; @@ -246,6 +247,8 @@ public class ImsDutyMainController extends BladeController { int mergeRowIndex = 2; // 需要合并的列 int[] mergeColumeIndex = {0}; + + ExcelTool.resetCellMaxTextLength(); // 导出Excel,合并第一列相同内容的单元格 EasyExcel.write(response.getOutputStream(), ImsDutyMainReportExcel.class) .registerWriteHandler(new ExcelMergeHandler(mergeRowIndex, mergeColumeIndex)).sheet().doWrite(list); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/utils/ExcelTool.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/utils/ExcelTool.java new file mode 100644 index 0000000..a0d56b3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/utils/ExcelTool.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.operational.duty.utils; + +import org.apache.poi.ss.SpreadsheetVersion; + +import java.lang.reflect.Field; + +/** + * 设置Excel导出的最大字符数 + * @author tanghaihao + * @date 2023年08月18日 16:40 + */ +public class ExcelTool { + + public static void resetCellMaxTextLength() { + SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; + if (Integer.MAX_VALUE != excel2007.getMaxTextLength()) { + Field field; + try { + field = excel2007.getClass().getDeclaredField("_maxTextLength"); + field.setAccessible(true); + field.set(excel2007, Integer.MAX_VALUE); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +}