Hello,
I have an excel file with a date column for which sorting doesn’t work. I followed the example here when creating my own application.
When I open excel manually and click the sort button it works. When I programmatically change the format to numbers and sort it works. Therefore it seems to be connected to the formatting as date. It doesn’t matter which kind of date formatting (YYYY-MM-DD or DD.MM.YYYY) I use, the issue persists. My Excel version is 2013.
My code:
var workbook = new Workbook(Path.Combine(path, "LayoutTestData.xlsx"));
var sorter = workbook.DataSorter;
sorter.Order1 = SortOrder.Descending;
sorter.Key1 = 0;
sorter.Order2 = SortOrder.Ascending;
sorter.Key2 = 1;
var ca = new CellArea
{
StartRow = 0,
StartColumn = 0,
EndRow = 20,
EndColumn = 2
};
sorter.Sort(workbook.Worksheets[0].Cells, ca);
workbook.Save(Path.Combine(path,"LayoutTestData.xlsx"));
The file:
LayoutTestData.zip (6.9 KB)
Thank you for your support and best regards
Stephan