From 77c0491aa11e8ffb2f2d3589e2eec64800a57482 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 26 Jan 2026 14:45:59 +0100 Subject: [PATCH] Color tab if the sheet contains a changed cell in ExcelComparer --- ENI2/Excel/ExcelComparer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ENI2/Excel/ExcelComparer.cs b/ENI2/Excel/ExcelComparer.cs index 28f32595..f13d5d04 100644 --- a/ENI2/Excel/ExcelComparer.cs +++ b/ENI2/Excel/ExcelComparer.cs @@ -55,8 +55,7 @@ namespace ENI2.Excel using (var sourceStream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var sourceWorkbook = new XLWorkbook(sourceStream)) - using (var comparisonStream = new FileStream(comparisonFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - using (var comparisonWorkbook = new XLWorkbook(comparisonStream)) + using (var comparisonWorkbook = new XLWorkbook(comparisonFileName)) { // Es werden Zellen der "used range" miteinander verglichen foreach (var sourceSheet in sourceWorkbook.Worksheets) @@ -78,6 +77,7 @@ namespace ENI2.Excel { int maxRows = Math.Max(sourceRows, targetRows); int maxCols = Math.Max(sourceCols, targetCols); + bool sheetHasDiffs = false; for (int rowidx = 1; rowidx <= maxRows; rowidx++) { @@ -113,6 +113,7 @@ namespace ENI2.Excel var cellToHighlight = targetSheet.Cell(rowidx, colidx); cellToHighlight.Style.Fill.BackgroundColor = diffColor; counter++; + sheetHasDiffs = true; } } else if (targetText == null) @@ -122,6 +123,7 @@ namespace ENI2.Excel var cellToHighlight = targetSheet.Cell(rowidx, colidx); cellToHighlight.Style.Fill.BackgroundColor = diffColor; counter++; + sheetHasDiffs = true; } } else if ((sourceText != null) && (targetText != null)) @@ -131,10 +133,16 @@ namespace ENI2.Excel var cellToHighlight = targetSheet.Cell(rowidx, colidx); cellToHighlight.Style.Fill.BackgroundColor = diffColor; counter++; + sheetHasDiffs = true; } } } } + + if (sheetHasDiffs) + { + targetSheet.SetTabColor(diffColor); + } } else {