Hi, Team E-ICEBlue
I am trying to load CSVfile then save it to excel and then fill it into data table but there an error occur. Kindly see the attachment below for reference.
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"CSVToExcel.csv", ",");
workbook.SaveToFile("result.xlsx",ExcelVersion.Version2016);
workbook.LoadFromFile(@"result.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
string text = worksheet.Columns[2].CellList[1].Text;
DateTime max = DateTime.ParseExact(text, "dd/MM/yy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
DateTime min = DateTime.ParseExact(text, "dd/MM/yy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
for (int i=2; i< worksheet.Columns[2].Count; i++)
{
string text1 = worksheet.Columns[2].CellList[i].Text;
if (DateTime.Compare(max, DateTime.ParseExact(text1, "dd/MM/yy HH:mm", System.Globalization.CultureInfo.InvariantCulture)) < 0)
{
max = DateTime.ParseExact(text1, "dd/MM/yy hh:mm", System.Globalization.CultureInfo.InvariantCulture);
}
if (DateTime.Compare(min, DateTime.ParseExact(text1, "dd/MM/yy HH:mm", System.Globalization.CultureInfo.InvariantCulture)) > 0)
{
min = DateTime.ParseExact(text1, "dd/MM/yy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
}
}
Console.WriteLine(max.ToString("dd/MM/yy H:mm"));
Console.WriteLine(min.ToString("dd/MM/yy H:mm"));
Console.ReadKey();