feat: 跳过没有ID的行

This commit is contained in:
2026-05-19 12:20:42 +08:00
parent b0afff73ac
commit 493ecfeb11
3 changed files with 12 additions and 3 deletions
+4
View File
@@ -83,6 +83,10 @@ namespace ExcelTool
IRow row = sheet.GetRow(i); IRow row = sheet.GetRow(i);
if (row == null) continue; if (row == null) continue;
// ID为空则跳过该行
if (string.IsNullOrEmpty(GetCellValue(row.GetCell(0)))) continue;
TableExcelRow tableExcelRow = new(); TableExcelRow tableExcelRow = new();
for (int j = 0; j < headers.Count; j++) for (int j = 0; j < headers.Count; j++)
tableExcelRow.Add(GetCellValue(row.GetCell(j))); tableExcelRow.Add(GetCellValue(row.GetCell(j)));
+6 -2
View File
@@ -119,7 +119,9 @@ namespace ExcelTool.Parser
if (idIndex < 0 || namesIndex < 0) continue; if (idIndex < 0 || namesIndex < 0) continue;
if (string.IsNullOrEmpty(row.StrList[idIndex])) continue; if (string.IsNullOrEmpty(row.StrList[idIndex])) continue;
uint id = Convert.ToUInt32(row.StrList[idIndex]); uint id = Convert.ToUInt32(row.StrList[idIndex]);
if (id == 0) continue; // 跳过ID=0的行
string rawNames = row.StrList[namesIndex]; string rawNames = row.StrList[namesIndex];
List<string> names = new(rawNames.Split(['|'], StringSplitOptions.RemoveEmptyEntries)); List<string> names = new(rawNames.Split(['|'], StringSplitOptions.RemoveEmptyEntries));
@@ -223,7 +225,9 @@ namespace ExcelTool.Parser
if (idIndex < 0 || namesIndex < 0) continue; if (idIndex < 0 || namesIndex < 0) continue;
if (string.IsNullOrEmpty(row.StrList[idIndex])) continue; if (string.IsNullOrEmpty(row.StrList[idIndex])) continue;
uint id = Convert.ToUInt32(row.StrList[idIndex]); uint id = Convert.ToUInt32(row.StrList[idIndex]);
if (id == 0) continue; // 跳过ID=0的行
string rawNames = row.StrList[namesIndex]; string rawNames = row.StrList[namesIndex];
List<string> names = new(rawNames.Split(['|'], StringSplitOptions.RemoveEmptyEntries)); List<string> names = new(rawNames.Split(['|'], StringSplitOptions.RemoveEmptyEntries));
+1
View File
@@ -203,6 +203,7 @@ namespace ExcelTool.Parser
if (string.IsNullOrEmpty(row.StrList[idIndex])) continue; if (string.IsNullOrEmpty(row.StrList[idIndex])) continue;
uint id = Convert.ToUInt32(row.StrList[idIndex]); uint id = Convert.ToUInt32(row.StrList[idIndex]);
if (id == 0) continue; // 跳过ID=0的行
// Names 是用分隔符(例如 '|')拼接的字符串 // Names 是用分隔符(例如 '|')拼接的字符串
string rawNames = row.StrList[namesIndex]; string rawNames = row.StrList[namesIndex];