From 7df7a4f46035ffb9411e3277cbd0eb1a1ddd15b6 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 12 Mar 2025 16:45:16 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=BF=9C=E7=A8=8Bexcel=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E4=BF=A1=E6=81=AF=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/datasource/provider/ExcelUtils.java | 15 +++++++-------- .../src/main/resources/i18n/core_en_US.properties | 6 ++++++ .../src/main/resources/i18n/core_zh_CN.properties | 6 ++++++ .../src/main/resources/i18n/core_zh_TW.properties | 6 ++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java index f354ee0276..6f1a43facf 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java @@ -22,11 +22,10 @@ import io.dataease.extensions.datasource.dto.DatasourceDTO; import io.dataease.extensions.datasource.dto.DatasourceRequest; import io.dataease.extensions.datasource.dto.TableField; import io.dataease.api.ds.vo.ExcelConfiguration; +import io.dataease.i18n.Translator; import io.dataease.utils.*; import lombok.Data; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.net.ftp.FTP; -import org.apache.commons.net.ftp.FTPClient; import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; @@ -435,7 +434,7 @@ public class ExcelUtils { } else if (remoteExcelRequest.getUrl().trim().startsWith("ftp")) { fileNames = downLoadFromFtp(remoteExcelRequest); } else { - DEException.throwException("不支持的协议!"); + DEException.throwException(Translator.get("i18n_unsupported_protocol")); } return fileNames; } @@ -671,7 +670,7 @@ public class ExcelUtils { for (int i = 0; i < split.length; i++) { String filedName = split[i]; if (StringUtils.isEmpty(filedName)) { - DEException.throwException("首行行中不允许有空单元格!"); + DEException.throwException(Translator.get("i18n_excel_error_first_row")); } if (filedName.startsWith(UFEFF)) { filedName = filedName.replace(UFEFF, ""); @@ -749,7 +748,7 @@ public class ExcelUtils { serverAddress = matcher.group(3); filePath = matcher.group(4); } else { - DEException.throwException("无效的地址!"); + DEException.throwException(Translator.get("i18n_invalid_address")); } } else { String regex = "ftp://([^/]+)(.*)"; @@ -759,13 +758,13 @@ public class ExcelUtils { serverAddress = matcher.group(1); filePath = matcher.group(2); } else { - DEException.throwException("无效的地址!"); + DEException.throwException(Translator.get("i18n_invalid_address")); } } filePath = filePath.startsWith("/") ? filePath.substring(1) : filePath; String suffix = filePath.substring(filePath.lastIndexOf(".") + 1); if (!Arrays.asList("csv", "xlsx", "xls").contains(suffix)) { - DEException.throwException("不支持的文件格式!"); + DEException.throwException(Translator.get("i18n_unsupported_file_format")); } String tranName = UUID.randomUUID().toString() + "." + suffix; String localFilePath = path + tranName; @@ -781,7 +780,7 @@ public class ExcelUtils { Process process = Runtime.getRuntime().exec(command); int exitValue = process.waitFor(); if (exitValue != 0) { - DEException.throwException("文件下载失败!"); + DEException.throwException(Translator.get("i18n_file_download_failed")); } } catch (IOException e) { e.printStackTrace(); diff --git a/core/core-backend/src/main/resources/i18n/core_en_US.properties b/core/core-backend/src/main/resources/i18n/core_en_US.properties index 13c7b0270f..63187cca0f 100644 --- a/core/core-backend/src/main/resources/i18n/core_en_US.properties +++ b/core/core-backend/src/main/resources/i18n/core_en_US.properties @@ -203,3 +203,9 @@ i18n_user_new_pwd_error=Password format: 8-20 characters and must include at lea i18n_user_pwd_same_error=Old and new passwords cannot be the same i18n_copilot_ds=Only supports MySQL datasource + +i18n_file_download_failed=File download failed! +i18n_unsupported_file_format=Unsupported file format! +i18n_invalid_address=Invalid address! +i18n_unsupported_protocol=Unsupported protocol! +i18n_excel_error_first_row=Empty cells are not allowed in the middle of the first row! diff --git a/core/core-backend/src/main/resources/i18n/core_zh_CN.properties b/core/core-backend/src/main/resources/i18n/core_zh_CN.properties index e7122b897b..776d6dc6ea 100644 --- a/core/core-backend/src/main/resources/i18n/core_zh_CN.properties +++ b/core/core-backend/src/main/resources/i18n/core_zh_CN.properties @@ -202,3 +202,9 @@ i18n_user_new_pwd_error=\u5BC6\u7801\u683C\u5F0F\uFF1A8-20\u4F4D\u4E14\u81F3\u5C i18n_user_pwd_same_error=\u65B0\u65E7\u5BC6\u7801\u4E0D\u80FD\u76F8\u540C i18n_copilot_ds=\u5F53\u524D\u4EC5\u652F\u6301MySQL\u6570\u636E\u6E90 + +i18n_file_download_failed=\u4e0b\u8f7d\u6587\u4ef6\u5931\u8d25\uff01 +i18n_unsupported_file_format=\u4e0d\u652f\u6301\u7684\u6587\u4ef6\u683c\u5f0f\uff01 +i18n_invalid_address=\u65e0\u6548\u7684\u5730\u5740\uff01 +i18n_unsupported_protocol=\u4e0d\u652f\u6301\u7684\u534f\u8bae\uff01 +i18n_excel_error_first_row=\u9996\u884c\u884c\u4e2d\u4e0d\u5141\u8bb8\u6709\u7a7a\u5355\u5143\u683c\uff01 diff --git a/core/core-backend/src/main/resources/i18n/core_zh_TW.properties b/core/core-backend/src/main/resources/i18n/core_zh_TW.properties index 030a292c3a..99b2a297d1 100644 --- a/core/core-backend/src/main/resources/i18n/core_zh_TW.properties +++ b/core/core-backend/src/main/resources/i18n/core_zh_TW.properties @@ -202,3 +202,9 @@ i18n_user_new_pwd_error=\u5BC6\u78BC\u683C\u5F0F\uFF1A8-20\u4F4D\u4E14\u81F3\u5C i18n_user_pwd_same_error=\u65B0\u820A\u5BC6\u78BC\u4E0D\u80FD\u76F8\u540C i18n_copilot_ds=\u7576\u524D\u50C5\u652F\u6301MySQL\u6578\u64DA\u6E90 + +i18n_file_download_failed=\u6587\u4ef6\u4e0b\u8f09\u5931\u6557\uff01 +i18n_unsupported_file_format=\u4e0d\u652f\u63f4\u7684\u6587\u4ef6\u683c\u5f0f\uff01 +i18n_invalid_address=\u7121\u6548\u7684\u5730\u5740\uff01 +i18n_unsupported_protocol=\u4e0d\u652f\u63f4\u7684\u5354\u8b70\uff01 +i18n_excel_error_first_row=\u9996\u884c\u884c\u4e2d\u4e0d\u5141\u8a31\u6709\u7a7a\u5132\u5b58\u683c\uff01