Browse Source

研究报告导出excel

guomengjiao 1 month ago
parent
commit
939a1eb1a6

+ 1 - 0
common/src/main/java/com/jeesite/common/constant/Constants.java

@@ -230,4 +230,5 @@ public interface Constants {
 
     String textFormat = "<p><span style=\"font-size: 16px; font-family: 微软雅黑;\">%s</span></p>";
     String textLineFormat = "</span></p><p><span style=\"font-size: 16px; font-family: 微软雅黑;\">";
+    int excelMax = 32767;
 }

+ 12 - 3
modules/report/src/main/java/com/jeesite/modules/report/web/ResearchReportController.java

@@ -348,10 +348,10 @@ public class ResearchReportController extends BaseController {
 		String lineStr = System.lineSeparator();
 		if(!list.isEmpty()){
 			listExcel = list.stream().map(vo -> {
-				vo.setReportScopeHtml(convertMarket(vo.getMarketScale(), vo.getMarketDriven(), vo.getLang()) + lineStr + lineStr + Html2PlainTxtUtils.convert(vo.getReportScopeHtml()));
-				vo.setDirectoryHtml(Html2PlainTxtUtils.convert(vo.getDirectoryHtml()));
+				vo.setReportScopeHtml(convertExcelStr(convertMarket(vo.getMarketScale(), vo.getMarketDriven(), vo.getLang()) + lineStr + lineStr + Html2PlainTxtUtils.convert(vo.getReportScopeHtml())));
+				vo.setDirectoryHtml(convertExcelStr(Html2PlainTxtUtils.convert(vo.getDirectoryHtml())));
 				vo.setMarketType(convertMarketType(vo.getMarketType(), vo.getLang()));
-				vo.setChartsHtml(Html2PlainTxtUtils.convert(vo.getChartsHtml()));
+				vo.setChartsHtml(convertExcelStr(Html2PlainTxtUtils.convert(vo.getChartsHtml())));
 				return vo;
 			}).collect(Collectors.toList());
 		}
@@ -361,6 +361,15 @@ public class ResearchReportController extends BaseController {
 		}
 	}
 
+	private String convertExcelStr(String str) {
+		if (StringUtils.isNotEmpty(str)) {
+			if (str.length() > Constants.excelMax) {
+				return null;
+			}
+		}
+		return str;
+	}
+
 	/**
 	 * 批量导出txt格式
 	 * @param researchReport