Program.cs 977 B

12345678910111213141516171819202122232425262728
  1. using ClosedXML.Excel;
  2. var path = @"d:\DEMONET\doc\S4采购执行_UAT测试报告v1.0.xlsx";
  3. using var wb = new XLWorkbook(path);
  4. int totalNormal = 0, totalEx = 0;
  5. foreach (var ws in wb.Worksheets)
  6. {
  7. var lastRow = ws.LastRowUsed()?.RowNumber() ?? 0;
  8. Console.WriteLine($" [{ws.Name}] rows={lastRow}");
  9. if (ws.Name == "目录") continue;
  10. for (int r = 12; r <= lastRow; r++)
  11. {
  12. var cell = ws.Cell(r, 1);
  13. if (cell.IsEmpty()) continue;
  14. var fill = cell.Style.Fill.BackgroundColor;
  15. var val = cell.Value.ToString();
  16. if (fill.HasValue && fill.ToString() == "FFFCE4D6")
  17. {
  18. if (!val.Contains("▼") && !val.Contains("注:")) totalEx++;
  19. }
  20. else if (val.StartsWith("4.") && !val.Contains("[异常]"))
  21. totalNormal++;
  22. }
  23. }
  24. Console.WriteLine($"正常用例: {totalNormal}");
  25. Console.WriteLine($"异常用例: {totalEx}");
  26. Console.WriteLine($"合计: {totalNormal + totalEx}");