Replaced ExcelDataReader with ClosedXML code in remaining functions

This commit is contained in:
Daniel Schick 2025-10-04 10:01:59 +02:00
parent a8adcb3167
commit 7a7ea56c0f
12 changed files with 670 additions and 767 deletions

View File

@ -2,23 +2,23 @@
// Description: Request dbh ids for Maersk data lists // Description: Request dbh ids for Maersk data lists
// //
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using bsmd.database; using bsmd.database;
using ExcelDataReader; using ClosedXML.Excel;
using System.Collections.ObjectModel;
using ENI2.Excel; using ENI2.Excel;
using ENI2.Locode; using ENI2.Locode;
using ENI2.Util; using ENI2.Util;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.Controls namespace ENI2.Controls
{ {
@ -336,80 +336,72 @@ namespace ENI2.Controls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row
}
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<MaerskData> importData = new List<MaerskData>(); List<MaerskData> importData = new List<MaerskData>();
bool isFirstRow = true; int currentRow = 1; // Start at 1 since we skip header
int currentRow = 0;
bool imosAreOkay = true; bool imosAreOkay = true;
try foreach (var row in rows)
{
while (reader.Read())
{ {
currentRow++; currentRow++;
if (isFirstRow) if (worksheet.RangeUsed().ColumnCount() < 13)
{
isFirstRow = false; // this must be a header row, skip
continue;
}
if (reader.FieldCount < 13)
{ {
throw new InvalidDataException("Sheet must have 13 columns of data"); throw new InvalidDataException("Sheet must have 13 columns of data");
} }
MaerskData md = new MaerskData(); MaerskData md = new MaerskData();
if (!reader.IsDBNull(0))
if (!row.Cell(1).IsEmpty())
{ {
if (reader.GetFieldType(0) == typeof(DateTime)) var cellValue = row.Cell(1).Value;
if (cellValue.IsDateTime)
{ {
md.ETA = reader.GetDateTime(0); var dateTime = cellValue.GetDateTime();
md.ETA = dateTime;
md.ColA = md.ETA.ToString(); md.ColA = md.ETA.ToString();
} }
else else
{ {
md.ColA = reader.GetString(0); md.ColA = row.Cell(1).GetString();
if (DateTime.TryParse(md.ColA, out DateTime aDateTime)) if (DateTime.TryParse(md.ColA, out DateTime aDateTime))
md.ETA = aDateTime; md.ETA = aDateTime;
} }
} }
if (!reader.IsDBNull(1)) md.ColB = reader.ReadAsString(1);
if (!reader.IsDBNull(2)) md.ColC = reader.ReadAsString(2); if (!row.Cell(2).IsEmpty()) md.ColB = row.Cell(2).GetString();
if (!reader.IsDBNull(3)) md.ColD = reader.ReadAsString(3); if (!row.Cell(3).IsEmpty()) md.ColC = row.Cell(3).GetString();
if (!reader.IsDBNull(4)) md.ColE = reader.ReadAsString(4); if (!row.Cell(4).IsEmpty()) md.ColD = row.Cell(4).GetString();
if (!reader.IsDBNull(5)) md.ColF = reader.ReadAsString(5); if (!row.Cell(5).IsEmpty()) md.ColE = row.Cell(5).GetString();
if (!reader.IsDBNull(6)) md.ColG = reader.ReadAsString(6); if (!row.Cell(6).IsEmpty()) md.ColF = row.Cell(6).GetString();
if (!reader.IsDBNull(7)) md.ColH = reader.ReadAsString(7); if (!row.Cell(7).IsEmpty()) md.ColG = row.Cell(7).GetString();
if (!reader.IsDBNull(8)) md.ColI = reader.ReadAsString(8); if (!row.Cell(8).IsEmpty()) md.ColH = row.Cell(8).GetString();
if (!row.Cell(9).IsEmpty()) md.ColI = row.Cell(9).GetString();
if (md.ColI != null) if (md.ColI != null)
{ {
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) || if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV"))) (md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import"); throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
} }
if (!reader.IsDBNull(9)) md.ColJ = reader.ReadAsString(9);
if (!row.Cell(10).IsEmpty()) md.ColJ = row.Cell(10).GetString();
if (md.ColJ == null) continue; if (md.ColJ == null) continue;
if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in
if (!reader.IsDBNull(10)) md.ColK = reader.ReadAsString(10);
if (!reader.IsDBNull(11)) md.ColL = reader.ReadAsString(11);
if (!reader.IsDBNull(12)) md.ColM = reader.ReadAsString(12);
if (!reader.IsDBNull(13)) md.Remark = reader.ReadAsString(13);
if(!md.ColF.IsNullOrEmpty()) if (!row.Cell(11).IsEmpty()) md.ColK = row.Cell(11).GetString();
if (!row.Cell(12).IsEmpty()) md.ColL = row.Cell(12).GetString();
if (!row.Cell(13).IsEmpty()) md.ColM = row.Cell(13).GetString();
if (!row.Cell(14).IsEmpty()) md.Remark = row.Cell(14).GetString();
if (!md.ColF.IsNullOrEmpty())
{ {
if (Int32.TryParse(md.ColF, out int imo)) if (Int32.TryParse(md.ColF, out int imo))
{ {
@ -435,13 +427,6 @@ namespace ENI2.Controls
} }
importData.Add(md); importData.Add(md);
if (isFirstRow) isFirstRow = false;
}
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
} }
if (imosAreOkay && importData.Count > 0) if (imosAreOkay && importData.Count > 0)
@ -471,10 +456,10 @@ namespace ENI2.Controls
if (md.MessageCore != null) if (md.MessageCore != null)
{ {
MaerskData existingMD = await DBManagerAsync.LoadMaerskDataForCoreAsync(md.MessageCore.Id.Value); MaerskData existingMD = await DBManagerAsync.LoadMaerskDataForCoreAsync(md.MessageCore.Id.Value);
if(existingMD == null) if (existingMD == null)
{ {
// we have a core but no MarskData for this import -> save it // we have a core but no MarskData for this import -> save it
md.MessageCoreId = (Guid) md.MessageCore.Id; md.MessageCoreId = (Guid)md.MessageCore.Id;
_ = DBManagerAsync.SaveAsync(md); _ = DBManagerAsync.SaveAsync(md);
} }
else else
@ -498,8 +483,11 @@ namespace ENI2.Controls
this.dataGridPOCores.Items.Refresh(); this.dataGridPOCores.Items.Refresh();
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -2,18 +2,16 @@
// Description: MDH Meldung Bearbeitungsseite // Description: MDH Meldung Bearbeitungsseite
// //
using System; using bsmd.database;
using System.Collections.Generic; using ClosedXML.Excel;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using System.IO;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database; using Microsoft.Win32;
using System;
using ExcelDataReader; using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -289,47 +287,44 @@ namespace ENI2.DetailViewControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed(); // Get all rows with data
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>(); List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) if (worksheet.RangeUsed().ColumnCount() < 3)
{
if (reader.FieldCount < 3)
{ {
throw new InvalidDataException("Sheet must have at least 3 Columns of data"); throw new InvalidDataException("Sheet must have at least 3 Columns of data");
} }
PortOfCallLast30Days poc30 = new PortOfCallLast30Days(); PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) poc30.PortOfCallLast30DaysLocode = reader.GetString(0); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysDateOfDeparture = reader.GetDateTime(1);
if (!row.Cell(1).IsEmpty()) poc30.PortOfCallLast30DaysLocode = row.Cell(1).GetString();
if (!row.Cell(2).IsEmpty()) poc30.PortOfCallLast30DaysDateOfDeparture = row.Cell(2).GetDateTime();
string boolString = ""; string boolString = "";
if (!reader.IsDBNull(2)) boolString = reader.GetString(2); if (!row.Cell(3).IsEmpty()) boolString = row.Cell(3).GetString();
poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) || (boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) || poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) ||
(boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) ||
(boolString.Equals("j", StringComparison.OrdinalIgnoreCase))); (boolString.Equals("j", StringComparison.OrdinalIgnoreCase)));
if(reader.FieldCount > 3) if (worksheet.RangeUsed().ColumnCount() > 3)
{ {
string allNewCrew = reader.GetString(3)?.Trim(); string allNewCrew = row.Cell(4).IsEmpty() ? null : row.Cell(4).GetString()?.Trim();
if(!allNewCrew.IsNullOrEmpty()) if (!allNewCrew.IsNullOrEmpty())
{ {
string[] crewNames = allNewCrew.Split(',', ';'); string[] crewNames = allNewCrew.Split(',', ';');
for(int i=0;i<crewNames.Length;i++) for (int i = 0; i < crewNames.Length; i++)
{ {
string crewName = crewNames[i].Trim(); string crewName = crewNames[i].Trim();
if (crewName.IsNullOrEmpty()) continue; if (crewName.IsNullOrEmpty()) continue;
@ -337,7 +332,6 @@ namespace ENI2.DetailViewControls
poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName; poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName;
poc30Crew.PortOfCallLast30Days = poc30; poc30Crew.PortOfCallLast30Days = poc30;
poc30.CrewJoinedShip.Add(poc30Crew); poc30.CrewJoinedShip.Add(poc30Crew);
} }
} }
} }
@ -346,12 +340,6 @@ namespace ENI2.DetailViewControls
this._mdh.PortOfCallLast30Days.Add(poc30); this._mdh.PortOfCallLast30Days.Add(poc30);
importPoC30.Add(poc30); importPoC30.Add(poc30);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPoC30.Count > 0) if (importPoC30.Count > 0)
{ {
@ -361,8 +349,11 @@ namespace ENI2.DetailViewControls
MessageBoxButton.OK, MessageBoxImage.Information); MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -2,18 +2,17 @@
// Description: SEC Meldung Bearbeitungsseite // Description: SEC Meldung Bearbeitungsseite
// //
using System.Windows; using bsmd.database;
using System.Windows.Controls; using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database;
using System.Windows.Data;
using System;
using Microsoft.Win32; using Microsoft.Win32;
using System.IO; using System;
using ExcelDataReader;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -345,53 +344,53 @@ namespace ENI2.DetailViewControls
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed(); // Get all rows with data
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>(); List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>();
try
{
do
{
int cnt = 0; int cnt = 0;
while (reader.Read() && (cnt < 10)) foreach (var row in rows)
{ {
if (((IExcelDataReader)reader).FieldCount < 8) if (cnt >= 10) break; // Maximum 10 rows
if (worksheet.RangeUsed().ColumnCount() < 8)
{ {
throw new InvalidDataException("Sheet must have 8 Columns of data"); throw new InvalidDataException("Sheet must have 8 Columns of data");
} }
LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled(); LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) l10c.PortFacilityPortName = reader.GetString(0); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!reader.IsDBNull(2)) l10c.PortFacilityPortCountry = reader.GetString(2);
if (!reader.IsDBNull(3)) l10c.PortFacilityPortLoCode = reader.GetString(3); if (!row.Cell(1).IsEmpty()) l10c.PortFacilityPortName = row.Cell(1).GetString();
if (!row.Cell(3).IsEmpty()) l10c.PortFacilityPortCountry = row.Cell(3).GetString();
if (!row.Cell(4).IsEmpty()) l10c.PortFacilityPortLoCode = row.Cell(4).GetString();
object o = null; object o = null;
if (!reader.IsDBNull(4)) o = reader.GetValue(4); if (!row.Cell(5).IsEmpty()) o = row.Cell(5).Value;
if(o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o); if (o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o);
if (!reader.IsDBNull(5)) o = reader.GetValue(5);
if (!row.Cell(6).IsEmpty()) o = row.Cell(6).Value;
if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o); if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o);
// if (!reader.IsDBNull(4)) l10c.PortFacilityDateOfArrival = reader.GetDateTime(4);
// if (!reader.IsDBNull(5)) l10c.PortFacilityDateOfDeparture = reader.GetDateTime(5); if (!row.Cell(7).IsEmpty()) o = row.Cell(7).Value;
if (!reader.IsDBNull(6)) o = reader.GetValue(6);
if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o); if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7);
if (!row.Cell(8).IsEmpty()) o = row.Cell(8).Value;
int gisis = Convert.ToInt32(o); int gisis = Convert.ToInt32(o);
if (!reader.IsDBNull(7)) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0'); if (!row.Cell(8).IsEmpty()) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0');
if (!reader.IsDBNull(8)) l10c.PortFacilitySecurityMattersToReport = reader.GetString(8);
if (l10c.PortFacilitySecurityMattersToReport.Equals("nil", StringComparison.CurrentCultureIgnoreCase)) if (!row.Cell(9).IsEmpty()) l10c.PortFacilitySecurityMattersToReport = row.Cell(9).GetString();
if (l10c.PortFacilitySecurityMattersToReport?.Equals("nil", StringComparison.CurrentCultureIgnoreCase) == true)
l10c.PortFacilitySecurityMattersToReport = null; l10c.PortFacilitySecurityMattersToReport = null;
if (!reader.IsDBNull(9)) l10c.PortFacilityGISISCodeLocode = reader.GetString(9);
if (!row.Cell(10).IsEmpty()) l10c.PortFacilityGISISCodeLocode = row.Cell(10).GetString();
l10c.SEC = this._sec; l10c.SEC = this._sec;
l10c.IsDirty = true; l10c.IsDirty = true;
l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled); l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled);
@ -399,12 +398,6 @@ namespace ENI2.DetailViewControls
importL10C.Add(l10c); importL10C.Add(l10c);
cnt++; cnt++;
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importL10C.Count > 0) if (importL10C.Count > 0)
{ {
@ -413,8 +406,11 @@ namespace ENI2.DetailViewControls
MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -2,17 +2,17 @@
// Description: Detailansicht Müllmeldung // Description: Detailansicht Müllmeldung
// //
using System.Linq; using bsmd.database;
using System.Collections.Generic; using ClosedXML.Excel;
using System.Windows;
using System.Windows.Controls;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using bsmd.database;
using ExcelDataReader;
using System.IO;
using System;
using Microsoft.Win32; using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.DetailViewControls namespace ENI2.DetailViewControls
{ {
@ -483,43 +483,30 @@ namespace ENI2.DetailViewControls
ofd.Filter = "Excel Files|*.xls;*.xlsx"; ofd.Filter = "Excel Files|*.xls;*.xlsx";
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(3); // Skip first three rows
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<Waste> importWasteList = new List<Waste>(); List<Waste> importWasteList = new List<Waste>();
try
{
do
{
// skip first three rows
reader.Read();
reader.Read();
reader.Read();
int cnt = 0; int cnt = 0;
object o = null; object o = null;
// Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen! // Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen!
while (reader.Read() && (cnt < 35)) foreach (var row in rows)
{ {
if (reader.FieldCount < 9) if (cnt >= 35) break; // Maximum 35 rows
if (worksheet.RangeUsed().ColumnCount() < 9)
{ {
throw new InvalidDataException("Sheet must have 9 Columns of data"); throw new InvalidDataException("Sheet must have 9 Columns of data");
} }
if (!reader.IsDBNull(1)) o = reader.GetValue(1); else o = null; if (!row.Cell(2).IsEmpty()) o = row.Cell(2).Value; else o = null;
if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType)) if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType))
{ {
Waste waste = _was.GetWasteForType(wasteType); Waste waste = _was.GetWasteForType(wasteType);
@ -537,22 +524,22 @@ namespace ENI2.DetailViewControls
waste.IsDirty = true; waste.IsDirty = true;
} }
if (!reader.IsDBNull(4)) waste.WasteDescription = reader.GetString(4); if (!row.Cell(5).IsEmpty()) waste.WasteDescription = row.Cell(5).GetString();
if (waste.WasteDescription.IsNullOrEmpty()) if (waste.WasteDescription.IsNullOrEmpty())
waste.WasteDescription = "-"; waste.WasteDescription = "-";
if (!reader.IsDBNull(5)) o = reader.GetValue(5); else o = null; if (!row.Cell(6).IsEmpty()) o = row.Cell(6).Value; else o = null;
if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o); if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(6)) o = reader.GetValue(6); else o = null; if (!row.Cell(7).IsEmpty()) o = row.Cell(7).Value; else o = null;
if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o); if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7); else o = null; if (!row.Cell(8).IsEmpty()) o = row.Cell(8).Value; else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o); if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8).ToUpper(); if (!row.Cell(9).IsEmpty()) waste.WasteDisposalPort = row.Cell(9).GetString().ToUpper();
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null; if (!row.Cell(10).IsEmpty()) o = row.Cell(10).Value; else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o); if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
importWasteList.Add(waste); importWasteList.Add(waste);
@ -560,13 +547,6 @@ namespace ENI2.DetailViewControls
} }
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importWasteList.Count > 0) if (importWasteList.Count > 0)
{ {
this.dataGridWaste.Items.Refresh(); this.dataGridWaste.Items.Refresh();
@ -574,9 +554,11 @@ namespace ENI2.DetailViewControls
MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -146,9 +146,6 @@
<Reference Include="DocumentFormat.OpenXml.Framework, Version=3.1.1.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL"> <Reference Include="DocumentFormat.OpenXml.Framework, Version=3.1.1.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>packages\DocumentFormat.OpenXml.Framework.3.1.1\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath> <HintPath>packages\DocumentFormat.OpenXml.Framework.3.1.1\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="ExcelDataReader, Version=3.8.0.0, Culture=neutral, PublicKeyToken=93517dbe6a4012fa, processorArchitecture=MSIL">
<HintPath>packages\ExcelDataReader.3.8.0\lib\net462\ExcelDataReader.dll</HintPath>
</Reference>
<Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL"> <Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
<HintPath>packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath> <HintPath>packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath>
</Reference> </Reference>

View File

@ -3,9 +3,9 @@
// //
using bsmd.database; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using ExcelDataReader;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -126,49 +126,46 @@ namespace ENI2.SheetDisplayControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
}
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<CREWD> importCrew = new List<CREWD>(); List<CREWD> importCrew = new List<CREWD>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) // Check if we have at least 13 columns
{ if (worksheet.RangeUsed().ColumnCount() < 13)
if (reader.FieldCount < 13)
{ {
throw new InvalidDataException("Sheet must have 13 columns of data"); throw new InvalidDataException("Sheet must have 13 columns of data");
} }
CREWD crew = new CREWD(); CREWD crew = new CREWD();
crew.IsDeparture = true; crew.IsDeparture = true;
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue; // Check if first two cells are empty
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1); if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2)); if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3).Clean();
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper(); if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5); if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper(); if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7); if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8)); if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9); if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper(); if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11); if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12); if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewdMessage; crew.MessageHeader = this._crewdMessage;
crew.IsDirty = true; crew.IsDirty = true;
@ -176,12 +173,6 @@ namespace ENI2.SheetDisplayControls
this._crewdMessage.Elements.Add(crew); this._crewdMessage.Elements.Add(crew);
importCrew.Add(crew); importCrew.Add(crew);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importCrew.Count > 0) if (importCrew.Count > 0)
{ {
@ -190,8 +181,11 @@ namespace ENI2.SheetDisplayControls
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -3,9 +3,9 @@
// //
using bsmd.database; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Util; using ENI2.Util;
using ExcelDataReader;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -166,47 +166,45 @@ namespace ENI2.SheetDisplayControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
}
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<CREW> importCrew = new List<CREW>(); List<CREW> importCrew = new List<CREW>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) // Check if we have at least 13 columns
{ if (worksheet.RangeUsed().ColumnCount() < 13)
if (reader.FieldCount < 13)
{ {
throw new InvalidDataException("Sheet must have 13 columns of data"); throw new InvalidDataException("Sheet must have 13 columns of data");
} }
CREW crew = new CREW(); CREW crew = new CREW();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0).Clean(); // Check if first two cells are empty
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue; if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1).Clean();
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2)); if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3).Clean(); if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5).Clean(); if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper(); if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7); if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8)); if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9).Clean(); if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper(); if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11); if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12).Clean(); if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
crew.MessageHeader = this._crewaMessage; crew.MessageHeader = this._crewaMessage;
crew.IsDirty = true; crew.IsDirty = true;
@ -214,12 +212,6 @@ namespace ENI2.SheetDisplayControls
this._crewaMessage.Elements.Add(crew); this._crewaMessage.Elements.Add(crew);
importCrew.Add(crew); importCrew.Add(crew);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importCrew.Count > 0) if (importCrew.Count > 0)
{ {
@ -228,8 +220,11 @@ namespace ENI2.SheetDisplayControls
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -3,10 +3,10 @@
// //
using bsmd.database; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Locode; using ENI2.Locode;
using ENI2.Util; using ENI2.Util;
using ExcelDataReader;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -144,69 +144,58 @@ namespace ENI2.SheetDisplayControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PASD> importPassenger = new List<PASD>(); List<PASD> importPassenger = new List<PASD>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) if (worksheet.RangeUsed().ColumnCount() < 17)
{
if (((IExcelDataReader)reader).FieldCount < 17)
{ {
throw new InvalidDataException("Sheet must have 17 columns of data"); throw new InvalidDataException("Sheet must have 17 columns of data");
} }
PASD pas = new PASD(); PASD pas = new PASD();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString(); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString(); if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2)); if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3);
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null) if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null; pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4); if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null) if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null; pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5)); if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper(); if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7); if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper(); if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9); if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10)); if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString( 11); if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper(); if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13); if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14); if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15); if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16); if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasMessage; pas.MessageHeader = this._pasdMessage;
pas.IsDirty = true; pas.IsDirty = true;
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements); pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
this._pasdMessage.Elements.Add(pas); this._pasdMessage.Elements.Add(pas);
importPassenger.Add(pas); importPassenger.Add(pas);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPassenger.Count > 0) if (importPassenger.Count > 0)
{ {
@ -215,7 +204,11 @@ namespace ENI2.SheetDisplayControls
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
stream.Close(); }
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -4,10 +4,10 @@
// //
using bsmd.database; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using ENI2.Locode; using ENI2.Locode;
using ENI2.Util; using ENI2.Util;
using ExcelDataReader;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -126,56 +126,51 @@ namespace ENI2.SheetDisplayControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PAS> importPassenger = new List<PAS>(); List<PAS> importPassenger = new List<PAS>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) if (worksheet.RangeUsed().ColumnCount() < 17)
{
if (((IExcelDataReader)reader).FieldCount < 17)
{ {
throw new InvalidDataException("Sheet must have 17 columns of data"); throw new InvalidDataException("Sheet must have 17 columns of data");
} }
PAS pas = new PAS(); PAS pas = new PAS();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString().Clean(); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString().Clean(); if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2)); if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3).Clean();
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null) if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null; pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4).Clean(); if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null) if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null; pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5)); if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper(); if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7).Clean(); if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean(); if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper().Clean();
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9); if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10)); if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString(11).Clean(); if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper(); if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13); if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14).Clean(); if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean(); if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16).Clean(); if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
pas.MessageHeader = this._pasMessage; pas.MessageHeader = this._pasMessage;
pas.IsDirty = true; pas.IsDirty = true;
@ -183,12 +178,6 @@ namespace ENI2.SheetDisplayControls
this._pasMessage.Elements.Add(pas); this._pasMessage.Elements.Add(pas);
importPassenger.Add(pas); importPassenger.Add(pas);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPassenger.Count > 0) if (importPassenger.Count > 0)
{ {
@ -197,7 +186,11 @@ namespace ENI2.SheetDisplayControls
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
stream.Close(); }
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -2,17 +2,16 @@
// Description: Display control of formsheet Tab 1. Voyage // Description: Display control of formsheet Tab 1. Voyage
// //
using System.Windows;
using bsmd.database; using bsmd.database;
using ClosedXML.Excel;
using ENI2.EditControls; using ENI2.EditControls;
using System.Windows.Controls;
using System;
using ENI2.Util; using ENI2.Util;
using System.Collections.Generic;
using ExcelDataReader;
using Microsoft.Win32; using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace ENI2.SheetDisplayControls namespace ENI2.SheetDisplayControls
@ -308,53 +307,53 @@ namespace ENI2.SheetDisplayControls
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed(); // Get all rows with data
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>(); List<LastTenPortFacilitiesCalled> importL10C = new List<LastTenPortFacilitiesCalled>();
try
{
do
{
int cnt = 0; int cnt = 0;
while (reader.Read() && (cnt < 10)) foreach (var row in rows)
{ {
if (((IExcelDataReader)reader).FieldCount < 8) if (cnt >= 10) break; // Maximum 10 rows
if (worksheet.RangeUsed().ColumnCount() < 8)
{ {
throw new InvalidDataException("Sheet must have 8 Columns of data"); throw new InvalidDataException("Sheet must have 8 Columns of data");
} }
LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled(); LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) l10c.PortFacilityPortName = reader.GetString(0); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!reader.IsDBNull(2)) l10c.PortFacilityPortCountry = reader.GetString(2);
if (!reader.IsDBNull(3)) l10c.PortFacilityPortLoCode = reader.GetString(3); if (!row.Cell(1).IsEmpty()) l10c.PortFacilityPortName = row.Cell(1).GetString();
if (!row.Cell(3).IsEmpty()) l10c.PortFacilityPortCountry = row.Cell(3).GetString();
if (!row.Cell(4).IsEmpty()) l10c.PortFacilityPortLoCode = row.Cell(4).GetString();
object o = null; object o = null;
if (!reader.IsDBNull(4)) o = reader.GetValue(4); if (!row.Cell(5).IsEmpty()) o = row.Cell(5).Value;
if (o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o); if (o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o);
if (!reader.IsDBNull(5)) o = reader.GetValue(5);
if (!row.Cell(6).IsEmpty()) o = row.Cell(6).Value;
if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o); if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o);
// if (!reader.IsDBNull(4)) l10c.PortFacilityDateOfArrival = reader.GetDateTime(4);
// if (!reader.IsDBNull(5)) l10c.PortFacilityDateOfDeparture = reader.GetDateTime(5); if (!row.Cell(7).IsEmpty()) o = row.Cell(7).Value;
if (!reader.IsDBNull(6)) o = reader.GetValue(6);
if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o); if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7);
if (!row.Cell(8).IsEmpty()) o = row.Cell(8).Value;
int gisis = Convert.ToInt32(o); int gisis = Convert.ToInt32(o);
if (!reader.IsDBNull(7)) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0'); if (!row.Cell(8).IsEmpty()) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0');
if (!reader.IsDBNull(8)) l10c.PortFacilitySecurityMattersToReport = reader.GetString(8);
if (l10c.PortFacilitySecurityMattersToReport.Equals("nil", StringComparison.CurrentCultureIgnoreCase)) if (!row.Cell(9).IsEmpty()) l10c.PortFacilitySecurityMattersToReport = row.Cell(9).GetString();
if (l10c.PortFacilitySecurityMattersToReport?.Equals("nil", StringComparison.CurrentCultureIgnoreCase) == true)
l10c.PortFacilitySecurityMattersToReport = null; l10c.PortFacilitySecurityMattersToReport = null;
if (!reader.IsDBNull(9)) l10c.PortFacilityGISISCodeLocode = reader.GetString(9);
if (!row.Cell(10).IsEmpty()) l10c.PortFacilityGISISCodeLocode = row.Cell(10).GetString();
l10c.SEC = this._sec; l10c.SEC = this._sec;
l10c.IsDirty = true; l10c.IsDirty = true;
l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled); l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled);
@ -362,12 +361,6 @@ namespace ENI2.SheetDisplayControls
importL10C.Add(l10c); importL10C.Add(l10c);
cnt++; cnt++;
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importL10C.Count > 0) if (importL10C.Count > 0)
{ {
@ -376,8 +369,11 @@ namespace ENI2.SheetDisplayControls
MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }
@ -453,43 +449,40 @@ namespace ENI2.SheetDisplayControls
}; };
if (ofd.ShowDialog() ?? false) if (ofd.ShowDialog() ?? false)
{ {
FileStream stream;
try try
{ {
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read); using (var workbook = new XLWorkbook(ofd.FileName))
}
catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); var worksheet = workbook.Worksheet(1); // Get first worksheet
return; var rows = worksheet.RangeUsed().RowsUsed(); // Get all rows with data
}
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>(); List<PortOfCallLast30Days> importPoC30 = new List<PortOfCallLast30Days>();
try foreach (var row in rows)
{ {
do if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
{
while (reader.Read()) if (worksheet.RangeUsed().ColumnCount() < 3)
{
if (reader.FieldCount < 3)
{ {
throw new InvalidDataException("Sheet must have at least 3 Columns of data"); throw new InvalidDataException("Sheet must have at least 3 Columns of data");
} }
PortOfCallLast30Days poc30 = new PortOfCallLast30Days(); PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) poc30.PortOfCallLast30DaysLocode = reader.GetString(0); if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysDateOfDeparture = reader.GetDateTime(1);
if (!row.Cell(1).IsEmpty()) poc30.PortOfCallLast30DaysLocode = row.Cell(1).GetString();
if (!row.Cell(2).IsEmpty()) poc30.PortOfCallLast30DaysDateOfDeparture = row.Cell(2).GetDateTime();
string boolString = ""; string boolString = "";
if (!reader.IsDBNull(2)) boolString = reader.GetString(2); if (!row.Cell(3).IsEmpty()) boolString = row.Cell(3).GetString();
poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) || (boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) || poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) ||
(boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) ||
(boolString.Equals("j", StringComparison.OrdinalIgnoreCase))); (boolString.Equals("j", StringComparison.OrdinalIgnoreCase)));
if (reader.FieldCount > 3) if (worksheet.RangeUsed().ColumnCount() > 3)
{ {
string allNewCrew = reader.GetString(3)?.Trim(); string allNewCrew = row.Cell(4).IsEmpty() ? null : row.Cell(4).GetString()?.Trim();
if (!allNewCrew.IsNullOrEmpty()) if (!allNewCrew.IsNullOrEmpty())
{ {
string[] crewNames = allNewCrew.Split(',', ';'); string[] crewNames = allNewCrew.Split(',', ';');
@ -501,7 +494,6 @@ namespace ENI2.SheetDisplayControls
poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName; poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName;
poc30Crew.PortOfCallLast30Days = poc30; poc30Crew.PortOfCallLast30Days = poc30;
poc30.CrewJoinedShip.Add(poc30Crew); poc30.CrewJoinedShip.Add(poc30Crew);
} }
} }
} }
@ -510,12 +502,6 @@ namespace ENI2.SheetDisplayControls
this._mdh.PortOfCallLast30Days.Add(poc30); this._mdh.PortOfCallLast30Days.Add(poc30);
importPoC30.Add(poc30); importPoC30.Add(poc30);
} }
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importPoC30.Count > 0) if (importPoC30.Count > 0)
{ {
@ -525,8 +511,11 @@ namespace ENI2.SheetDisplayControls
MessageBoxButton.OK, MessageBoxImage.Information); MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
stream.Close(); catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
} }

View File

@ -3,7 +3,7 @@
// //
using bsmd.database; using bsmd.database;
using ExcelDataReader;
using System; using System;
namespace ENI2.Util namespace ENI2.Util
@ -11,20 +11,6 @@ namespace ENI2.Util
internal static class Extensions internal static class Extensions
{ {
public static string ReadAsString(this IExcelDataReader reader, int index)
{
if (index >= reader.FieldCount) return null;
Type fieldType = reader.GetFieldType(index);
if (fieldType == null) return null;
if (fieldType == typeof(string))
return reader.GetString(index).Clean();
if (fieldType == typeof(DateTime))
return reader.GetDateTime(index).ToString();
if (fieldType == typeof(int))
return reader.GetInt32(index).ToString();
if (fieldType == typeof(double))
return ((int)reader.GetDouble(index)).ToString();
return null;
}
} }
} }

View File

@ -4,7 +4,6 @@
<package id="ClosedXML.Parser" version="2.0.0" targetFramework="net48" /> <package id="ClosedXML.Parser" version="2.0.0" targetFramework="net48" />
<package id="DocumentFormat.OpenXml" version="3.1.1" targetFramework="net48" /> <package id="DocumentFormat.OpenXml" version="3.1.1" targetFramework="net48" />
<package id="DocumentFormat.OpenXml.Framework" version="3.1.1" targetFramework="net48" /> <package id="DocumentFormat.OpenXml.Framework" version="3.1.1" targetFramework="net48" />
<package id="ExcelDataReader" version="3.8.0" targetFramework="net48" />
<package id="ExcelNumberFormat" version="1.1.0" targetFramework="net48" /> <package id="ExcelNumberFormat" version="1.1.0" targetFramework="net48" />
<package id="Extended.Wpf.Toolkit" version="5.0.0" targetFramework="net48" /> <package id="Extended.Wpf.Toolkit" version="5.0.0" targetFramework="net48" />
<package id="log4net" version="3.2.0" targetFramework="net48" /> <package id="log4net" version="3.2.0" targetFramework="net48" />