diff --git a/laws-base/laws-base-core/src/main/java/com/jero/config/ApplicationCommandLine.java b/laws-base/laws-base-core/src/main/java/com/jero/config/ApplicationCommandLine.java new file mode 100644 index 00000000..414084ee --- /dev/null +++ b/laws-base/laws-base-core/src/main/java/com/jero/config/ApplicationCommandLine.java @@ -0,0 +1,24 @@ +package com.jero.config; + +import org.apache.poi.ss.SpreadsheetVersion; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Field; + +/** + * 解决导出excel单元格长度过长问题 + * @version 1.0 + * @date 2024/9/5 15:16 + */ +@Component +public class ApplicationCommandLine implements CommandLineRunner { + @Override + public void run(String... args) throws Exception { + SpreadsheetVersion spreadsheetVersion = SpreadsheetVersion.EXCEL2007; + Field maxTextLength = spreadsheetVersion.getClass().getDeclaredField("_maxTextLength"); + maxTextLength.setAccessible(true); + maxTextLength.set(spreadsheetVersion, Integer.MAX_VALUE); + } +} + diff --git a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java index 407a0036..a785ec8a 100644 --- a/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/activiti/process/standardinterpret/service/impl/StandardInterpretFlowServiceImpl.java @@ -1084,7 +1084,6 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe exportList = BeanCopyUtils.copyBeanList(exportList2, ProcessStandardInterpretClauseSublist.class); } - resetCellMaxTextLength(); // Step.3 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); try { @@ -1102,23 +1101,6 @@ public class StandardInterpretFlowServiceImpl implements StandardInterpretFlowSe return mv; } - public static void resetCellMaxTextLength() { - SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; - if (Integer.MAX_VALUE != excel2007.getMaxTextLength()) { - Field field; - try { - // SpreadsheetVersion.EXCEL2007的_maxTextLength变量 - field = excel2007.getClass().getDeclaredField("_maxTextLength"); - // 关闭反射机制的安全检查,可以提高性能 - field.setAccessible(true); - // 重新设置这个变量属性值 - field.set(excel2007, Integer.MAX_VALUE); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - @Override public void flowCountersign(String taskId, String userId, String projectId) { ProcessStandardInterpret processStandardInterpret = processStandardInterpretService.getOne(