fix(测试跟踪): 缺陷管理导出EXCEL单元格TEXT长度大于POI限制的单元格长度时错误
This commit is contained in:
parent
5529715b26
commit
acfa6992f6
|
@ -6,12 +6,11 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.exception.ExcelException;
|
import org.apache.poi.ss.SpreadsheetVersion;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -98,4 +97,19 @@ public class EasyExcelExporter {
|
||||||
MSException.throwException(e.getMessage());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1461,6 +1461,7 @@ public class IssuesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void issueExport(IssueExportRequest request, HttpServletResponse response) {
|
public void issueExport(IssueExportRequest request, HttpServletResponse response) {
|
||||||
|
EasyExcelExporter.resetCellMaxTextLength();
|
||||||
Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName));
|
Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName));
|
||||||
// 获取缺陷模板及自定义字段
|
// 获取缺陷模板及自定义字段
|
||||||
IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId());
|
IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId());
|
||||||
|
|
Loading…
Reference in New Issue