Commit a7e048c2 by wyc

自定义提取(值保留前面的0)

parent fb64f6f7
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.OpenXmlFormats.Dml.Chart;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using Performance.DtoModels; using Performance.DtoModels;
...@@ -117,10 +118,12 @@ public static void SetValue(this ISheet sheet, int row, int column, object value ...@@ -117,10 +118,12 @@ public static void SetValue(this ISheet sheet, int row, int column, object value
switch (value) switch (value)
{ {
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*[.]?\d*$"): case string reg when Regex.IsMatch(reg, @"^[+-]?\d*[.]?\d*$"):
if (!reg.StartsWith('0') || reg.Length == 1)
value = ConvertHelper.To<double>(value); value = ConvertHelper.To<double>(value);
break; break;
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*$"): case string reg when Regex.IsMatch(reg, @"^[+-]?\d*$"):
if (!reg.StartsWith('0') || reg.Length == 1)
value = ConvertHelper.To<int>(value); value = ConvertHelper.To<int>(value);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment