Color tab if the sheet contains a changed cell in ExcelComparer
This commit is contained in:
parent
d02cb0d56b
commit
77c0491aa1
@ -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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user