| 12345678910111213141516171819202122232425262728 |
- using ClosedXML.Excel;
- var path = @"d:\DEMONET\doc\S4采购执行_UAT测试报告v1.0.xlsx";
- using var wb = new XLWorkbook(path);
- int totalNormal = 0, totalEx = 0;
- foreach (var ws in wb.Worksheets)
- {
- var lastRow = ws.LastRowUsed()?.RowNumber() ?? 0;
- Console.WriteLine($" [{ws.Name}] rows={lastRow}");
- if (ws.Name == "目录") continue;
- for (int r = 12; r <= lastRow; r++)
- {
- var cell = ws.Cell(r, 1);
- if (cell.IsEmpty()) continue;
- var fill = cell.Style.Fill.BackgroundColor;
- var val = cell.Value.ToString();
- if (fill.HasValue && fill.ToString() == "FFFCE4D6")
- {
- if (!val.Contains("▼") && !val.Contains("注:")) totalEx++;
- }
- else if (val.StartsWith("4.") && !val.Contains("[异常]"))
- totalNormal++;
- }
- }
- Console.WriteLine($"正常用例: {totalNormal}");
- Console.WriteLine($"异常用例: {totalEx}");
- Console.WriteLine($"合计: {totalNormal + totalEx}");
|