From 970fa22e54f65b81f9ebd52b98f177643a6f3805 Mon Sep 17 00:00:00 2001 From: xinzhyu Date: Thu, 8 Jun 2023 13:42:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B0=E5=80=BC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8E=BB=E6=8E=89=E5=8D=83=E5=88=86=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.props | 2 +- .../Utility/ImportHelper.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common.props b/common.props index 715c4f78..647b8078 100644 --- a/common.props +++ b/common.props @@ -1,6 +1,6 @@ - 2.7.4.4 + 2.7.4.100 true snupkg 1591 diff --git a/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs b/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs index 6d34d4ff..6d2b3a9c 100644 --- a/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs +++ b/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs @@ -1095,7 +1095,7 @@ protected virtual void ParseData(ExcelPackage excelPackage) } var value = col.MappingValues[cellValue]; - + if (isEnum && isNullable && (value is int || value is short) // && Enum.IsDefined(type, value) ) @@ -1156,6 +1156,15 @@ protected virtual void ParseData(ExcelPackage excelPackage) continue; } + #region 删除千分位符 "," + var types = new string[] { "Int64", "Nullable", "Int32", "Nullable", "Int16", "Nullable", "Decimal", "Nullable", "Double", "Nullable" }; + var csType = propertyInfo.PropertyType.GetCSharpTypeName(); + if (types.Contains(csType)) + { + cellValue = cellValue?.Replace(",", ""); + } + #endregion + switch (propertyInfo.PropertyType.GetCSharpTypeName()) { case "Boolean": From 537b3d69e35de2070c59d1eeb43b850fb3109629 Mon Sep 17 00:00:00 2001 From: xinzhyu Date: Sun, 25 Jun 2023 11:40:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8D=95=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utility/ImportHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs b/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs index 6d2b3a9c..9193ab31 100644 --- a/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs +++ b/src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs @@ -1156,12 +1156,12 @@ protected virtual void ParseData(ExcelPackage excelPackage) continue; } - #region 删除千分位符 "," + #region 删除千分位符 "," 及单引号 "'" var types = new string[] { "Int64", "Nullable", "Int32", "Nullable", "Int16", "Nullable", "Decimal", "Nullable", "Double", "Nullable" }; var csType = propertyInfo.PropertyType.GetCSharpTypeName(); if (types.Contains(csType)) { - cellValue = cellValue?.Replace(",", ""); + cellValue = cellValue?.Replace(",", "").Replace("'", ""); } #endregion