From 67d66c54813ef4d9f2787fcf339e31ac655cc970 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 28 Jul 2021 12:06:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A4=E6=96=ADexcel=20=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E8=A1=8C=E4=B8=8D=E4=B8=BA=E7=A9=BA=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=9C=89=E7=A9=BA=E5=8D=95=E5=85=83=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/commons/utils/ExcelXlsReader.java | 11 ----------- .../io/dataease/commons/utils/ExcelXlsxReader.java | 4 ++++ .../dataease/service/dataset/DataSetTableService.java | 3 +++ .../src/main/resources/i18n/messages_en_US.properties | 1 + .../src/main/resources/i18n/messages_zh_CN.properties | 1 + .../src/main/resources/i18n/messages_zh_TW.properties | 1 + 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsReader.java b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsReader.java index 7a12665e48..97f4306939 100644 --- a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsReader.java +++ b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsReader.java @@ -206,17 +206,6 @@ public class ExcelXlsReader implements HSSFListener { thisRow = frec.getRow(); thisColumn = frec.getColumn(); thisStr = String.valueOf(frec.getValue()); -// if (outputFormulaValues) { -// if (Double.isNaN(frec.getValue())) { -// outputNextStringRecord = true; -// nextRow = frec.getRow(); -// nextColumn = frec.getColumn(); -// } else { -// thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"'; -// } -// } else { -// thisStr = '"' + HSSFFormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"'; -// } String feildType = checkType(thisStr, thisColumn); if(feildType.equalsIgnoreCase("LONG") && thisStr.endsWith(".0")){ thisStr = thisStr.substring(0, thisStr.length() -2); diff --git a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java index fd0aa4ca8f..dc57e3a523 100644 --- a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java +++ b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java @@ -4,6 +4,7 @@ import io.dataease.datasource.dto.TableFiled; import io.dataease.dto.dataset.ExcelSheetData; import io.dataease.i18n.Translator; import io.dataease.service.message.MsgAop; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.ss.usermodel.BuiltinFormats; @@ -410,6 +411,9 @@ public class ExcelXlsxReader extends DefaultHandler { tableFiled.setRemarks(thisStr); this.fields.add(tableFiled); }else { + if(CollectionUtils.isEmpty(this.getFields())){ + throw new RuntimeException(Translator.get("i18n_excel_header_empty")); + } this.getFields().get(curCol).setFieldType(type); } return thisStr; diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 38c8241995..c15b9d5902 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1402,6 +1402,9 @@ public class DataSetTableService { public static boolean checkIsRepeat(String[] array) { HashSet hashSet = new HashSet(); for (int i = 0; i < array.length; i++) { + if(StringUtils.isEmpty(array[i])){ + throw new RuntimeException(Translator.get("i18n_excel_empty_column")); + } hashSet.add(array[i]); } if (hashSet.size() == array.length) { diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 4368a78131..5ec1221582 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -255,6 +255,7 @@ i18n_dataset_delete_or_no_permission=Data set is delete or no permission i18n_chart_delete=Chart is delete i18n_not_exec_add_sync=There is no completed synchronization task. Incremental synchronization cannot be performed i18n_excel_header_empty=Excel first row can not empty +i18n_excel_empty_column=There are empty cells in the first row i18n_custom_ds_delete=Custom dataset union data is deleted,can not display i18n_sql_add_not_matching=The data column of incremental SQL does not match the dataset, i18n_sql_delete_not_matching=The data column of incremental delete SQL does not match the dataset, diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 4611604efa..ef4367caf8 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -254,6 +254,7 @@ i18n_dataset_delete_or_no_permission=当前用到的数据集没有权限或已 i18n_chart_delete=当前用到的视图已被删除 i18n_not_exec_add_sync=没有已完成的同步任务,无法进行增量同步 i18n_excel_header_empty=Excel第一行为空 +i18n_excel_empty_column=第一行存在空单元格 i18n_custom_ds_delete=自定义数据集所关联数据被删除,无法正常显示 i18n_sql_add_not_matching=增量添加 sql 的数据列与数据集不匹配, i18n_sql_delete_not_matching=增量删除 sql 的数据列与数据集不匹配, diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index be40e15ffa..e3fa5293ba 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -257,6 +257,7 @@ i18n_dataset_delete_or_no_permission=當前用到的數據集沒有權限或已 i18n_chart_delete=當前用到的視圖已被刪除 i18n_not_exec_add_sync=沒有已經完成的同步任務,無法進行增量同步 i18n_excel_header_empty=Excel第一行為空 +i18n_excel_empty_column=第一行存在空單元格 i18n_custom_ds_delete=自定義數據集所關聯數據被刪除,無法正常顯示 i18n_sql_add_not_matching=增量添加 sql 的數據列與數據集不匹配, i18n_sql_delete_not_matching=增量刪除 sql 的數據列與數據集不匹配,