diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java index 6a52c6ef59..884bc84646 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java @@ -6,12 +6,11 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; -import io.metersphere.exception.ExcelException; -import org.apache.commons.collections.CollectionUtils; +import org.apache.poi.ss.SpreadsheetVersion; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -98,4 +97,19 @@ public class EasyExcelExporter { MSException.throwException(e.getMessage()); } } + + public static void resetCellMaxTextLength() { + SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; + if (excel2007.getMaxTextLength() < Integer.MAX_VALUE) { + Field field; + try { + field = excel2007.getClass().getDeclaredField("_maxTextLength"); + field.setAccessible(Boolean.TRUE); + field.set(excel2007, Integer.MAX_VALUE); + }catch (Exception e){ + LogUtil.error(e); + MSException.throwException(e.getMessage()); + } + } + } } diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index e7c04b528a..44d1cba6dd 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -1462,6 +1462,7 @@ public class IssuesService { } public void issueExport(IssueExportRequest request, HttpServletResponse response) { + EasyExcelExporter.resetCellMaxTextLength(); Map userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName)); // 获取缺陷模板及自定义字段 IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId());