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,18 +54,19 @@ 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)
|
||||
{
|
||||
if (!source.NameDict.ContainsKey(name)) continue;
|
||||
string sourceText = source.ReadText(name);
|
||||
string targetText = comparison.ReadText(name);
|
||||
string targetText = comparison.ReadText(name);
|
||||
|
||||
if (sourceText == null)
|
||||
{
|
||||
if (targetText != null)
|
||||
{
|
||||
comparison.Colorize(name, diffColor);
|
||||
comparison.Colorize(name, diffColor);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@ -53,7 +74,7 @@ namespace ENI2.Excel
|
||||
{
|
||||
if (sourceText != null)
|
||||
{
|
||||
comparison.Colorize(name, diffColor);
|
||||
comparison.Colorize(name, diffColor);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@ -62,11 +83,14 @@ namespace ENI2.Excel
|
||||
if (!sourceText.Equals(targetText))
|
||||
{
|
||||
// turn cell blue
|
||||
comparison.Colorize(name, diffColor);
|
||||
comparison.Colorize(name, diffColor);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
comparison.Save(fileName);
|
||||
errorMessage = string.Format("{0} differences found", counter);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace bsmd.database
|
||||
STRING_UNNUMBER = 23,
|
||||
STRING_IMOCLASS = 24,
|
||||
DRAUGHT_IMPLAUSIBLE = 25,
|
||||
TIME_IMPLAUSIBLE = 26,
|
||||
TIME_IMPLAUSIBLE = 26,
|
||||
PORTAREA,
|
||||
TRUNCATE = 28,
|
||||
MMSI = 29,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user