From 30d73ddf15a58df9ebd429052e5e7a7b56ab8a49 Mon Sep 17 00:00:00 2001 From: Oliver Wong Date: Wed, 25 Mar 2026 19:23:45 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=98=BE=E7=A4=BA=E5=A3=B0=E6=98=8E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20-=20=E4=BD=BF=E7=94=A8=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E8=AE=BF=E9=97=AE=E5=99=A8=20-=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ExcelTool/Parser/TableExcelData.cs | 26 ++++++++--------------- ExcelTool/Parser/TableExcelExportBytes.cs | 2 +- ExcelTool/Program.cs | 2 +- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ExcelTool/Parser/TableExcelData.cs b/ExcelTool/Parser/TableExcelData.cs index 17d1ec1..7f1d7ec 100644 --- a/ExcelTool/Parser/TableExcelData.cs +++ b/ExcelTool/Parser/TableExcelData.cs @@ -5,28 +5,20 @@ namespace ExcelTool.Parser { public class TableExcelData { - List headers = new(); - List rows = new(); - public int CollonCount = 0; - public int RowCounts = 0; + public readonly int ColumnCount = 0; + public readonly int RowCounts = 0; + + public List Headers { get; } + public List Rows { get; } public TableExcelData(IEnumerable headers, IEnumerable rows) { - this.headers = headers.ToList(); - this.rows = rows.ToList(); - this.CollonCount = this.headers.Count; - this.RowCounts = this.rows.Count; + Headers = headers.ToList(); + Rows = rows.ToList(); + this.ColumnCount = Headers.Count; + this.RowCounts = Rows.Count; } - public List Headers - { - get { return this.headers; } - } - - public List Rows - { - get { return this.rows; } - } //TODO:待检查数据类型的合法性 //public bool CheckUnique(out string errorMsg) diff --git a/ExcelTool/Parser/TableExcelExportBytes.cs b/ExcelTool/Parser/TableExcelExportBytes.cs index 4aba69b..df33dad 100644 --- a/ExcelTool/Parser/TableExcelExportBytes.cs +++ b/ExcelTool/Parser/TableExcelExportBytes.cs @@ -18,7 +18,7 @@ namespace ExcelTool.Parser datas.Add(rowCount); foreach (var row in sheet.Data.Rows) { - for (int i = 0; i < sheet.Data.CollonCount; i++) + for (int i = 0; i < sheet.Data.ColumnCount; i++) { var type = sheet.Data.Headers[i].FieldType.ToLower(); var data = row.StrList[i]; diff --git a/ExcelTool/Program.cs b/ExcelTool/Program.cs index d506159..21eac2b 100644 --- a/ExcelTool/Program.cs +++ b/ExcelTool/Program.cs @@ -14,7 +14,7 @@ namespace ExcelTool string outputDataDir = ""; string nameSpace = ""; - foreach (var arg in args) + foreach (string arg in args) { if (arg.StartsWith("--input=")) {