Excel Vergleich Umbau Teil 1
This commit is contained in:
parent
cccc2aee3c
commit
e8a4fcb227
@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
|
||||
namespace ENI2.Excel
|
||||
{
|
||||
@ -22,6 +23,25 @@ namespace ENI2.Excel
|
||||
{
|
||||
private static int diffColor = ColorTranslator.ToOle(Color.FromArgb(150, 150, 255)); // blue
|
||||
|
||||
private static bool GetSheetRange(Worksheet sheet, out int lastUsedRow, out int lastUsedColumn)
|
||||
{
|
||||
try
|
||||
{
|
||||
Range last = sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing);
|
||||
Range range = sheet.get_Range("A1", last);
|
||||
|
||||
lastUsedRow = last.Row;
|
||||
lastUsedColumn = last.Column;
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
lastUsedColumn = 0;
|
||||
lastUsedRow = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Compare(string sourcePath, string targetPath, out string errorMessage)
|
||||
{
|
||||
string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xlsx";
|
||||
@ -34,6 +54,7 @@ namespace ENI2.Excel
|
||||
ExcelReader source = new ExcelReader(sourcePath);
|
||||
ExcelReader comparison = new ExcelReader(fileName, false);
|
||||
|
||||
/*
|
||||
// loop through named cells
|
||||
foreach (string name in comparison.NameDict.Keys)
|
||||
{
|
||||
@ -67,6 +88,9 @@ namespace ENI2.Excel
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
comparison.Save(fileName);
|
||||
errorMessage = string.Format("{0} differences found", counter);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user