We can encountered a problem where it appears that Aspose.Cells is not using the computer’s Region and Language settings (at least as it pertains to the Short Date format).
I have attached two files “ExcelTest_NADateFormat.xls” and “ExcelTest_UKDateFormat.xls”. The “NA” file was created with the computer’s Region and Language setting to "English (United States) which causes the short date format to be “MM/DD/YYYY”. The “UK” file was created with the computer’s Region and Language setting to “English (United Kingdom)” which causes the short date format to be “DD/MM/YYYY”. The formatting of these cells in both files is set to a Date whose format has an “*” - which should mean that the way the date is displayed should change with the operating system setting’s chosen Region and Language.
If you run the following code using Aspose.Cells version 7.0.2.0, the values in the resulting DataTables are the same. If you have your Region and Language settings to US, all the dates in both DataTables appear as “MM/DD/YYYY” formatted. If you are set to be UK, all the dates in both DataTables appear as “DD/MM/YYYY” formatted.
However, if you use Aspose.Cells version 7.3 or 7.4, the values do not match. The values in the DataTable created from the “US” file are always “MM/DD/YYYY” formatted and the values in the DataTable created from the “UK” file are always “DD/MM/YYYY” formatted. And this is regardless of how the computer’s Region and Language settings are configured.
Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions();
//This file was create with the PC’s Region and Language Date Format to be English (United States) so that the short datetime format is ‘MM/DD/YYYY’
//The format on the excel was set “*” so that it’s date format would switch with the operating system settings
string excelFileNameAndPathNA = "c:\\ExcelTest_NADateFormat.xls";
Aspose.Cells.Workbook excelFileNA = new Aspose.Cells.Workbook(excelFileNameAndPathNA, loadOptions);
//This file was create with the PC’s Region and Language Date Format to be English (United Kingdom) so that the short datetime format is ‘DD/MM/YYYY’
//The format on the excel was set “*” so that it’s date format would switch with the operating system settings
string excelFileNameAndPathUK = "c:\\ExcelTest_UKDateFormat.xls";
Aspose.Cells.Workbook excelFileUK = new Aspose.Cells.Workbook(excelFileNameAndPathUK, loadOptions);
//Export the worksheet as a datatable of strings
Aspose.Cells.Worksheet currentWorksheetNA = excelFileNA.Worksheets["Sheet1"];
System.Data.DataTable cultureTableNA1 = currentWorksheetNA.Cells.ExportDataTableAsString(0, 0, currentWorksheetNA.Cells.MaxDataRow + 1, currentWorksheetNA.Cells.MaxDataColumn + 1);
Aspose.Cells.Worksheet currentWorksheetUK = excelFileUK.Worksheets["Sheet1"];
System.Data.DataTable cultureTableUK1 = currentWorksheetUK.Cells.ExportDataTableAsString(0, 0, currentWorksheetUK.Cells.MaxDataRow + 1, currentWorksheetUK.Cells.MaxDataColumn + 1);
This change from the way it was being handled is causing us some problems in our handling of data from non-US clients. Is this a bug in the later versions of Aspose? Is there some other way we should be handling the files in order for the dates to appear consistently based upon the region settings?