Merge pull request #5024 from dataease/pr@dev@fix_report_viewname

fix(定时报告): 导出视图名称包含"/"报错
This commit is contained in:
fit2cloud-chenyw 2023-04-13 15:55:50 +08:00 committed by GitHub
commit 616b0efad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,8 @@ import io.dataease.commons.model.excel.ExcelSheetModel;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -29,6 +31,9 @@ public class ExcelUtils {
List<List<String>> details = sheet.getData(); List<List<String>> details = sheet.getData();
details.add(0, sheet.getHeads()); details.add(0, sheet.getHeads());
String sheetName = sheet.getSheetName(); String sheetName = sheet.getSheetName();
Pattern pattern = Pattern.compile("[\\s\\\\/:\\*\\?\\\"<>\\|]");
Matcher matcher = pattern.matcher(sheetName);
sheetName = matcher.replaceAll("-");
Sheet curSheet = wb.createSheet(sheetName); Sheet curSheet = wb.createSheet(sheetName);
if (StringUtils.isBlank(fileName)) { if (StringUtils.isBlank(fileName)) {
String cName = sheetName + suffix; String cName = sheetName + suffix;