feat: 跳过没有ID的行
This commit is contained in:
@@ -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)));
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|
||||||
|
|||||||
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user