fix: 判断excel 第一行不为空并且不能有空单元格

This commit is contained in:
taojinlong 2021-07-28 12:06:19 +08:00
parent beeae23d9f
commit 67d66c5481
6 changed files with 10 additions and 11 deletions

View File

@ -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);

View File

@ -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;

View File

@ -1402,6 +1402,9 @@ public class DataSetTableService {
public static boolean checkIsRepeat(String[] array) {
HashSet<String> hashSet = new HashSet<String>();
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) {

View File

@ -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,

View File

@ -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 的数据列与数据集不匹配,

View File

@ -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 的數據列與數據集不匹配,