I'm working with a legacy system that has components made several years ago (Excel macros) which I'm now trying to integrate into a more user friendly .net application. The files I am accessing are tab-delimited datasheets saved as __.xls so they're opened automatically by Excel when double-clicked.
Inside the sheet there are various dates in the format "dd/MM/yyyy", and when the file is opened normally (double clicked, right-click open, etc) via Excel 2003 (required version), the dates are interpreted as such. When I attempt to open the file using the Microsoft.Office.Interop.Excel (14.0.4756.1000) library however, (i.e. invoke via c#) using the following syntax:
eit_book = eit_books.Open(targetFile.FullName, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
the dates have their day and month switched, and all date math done in the aforementioned macros is done incorrectly. (As well as any dates where the day is greater than 12 are not even recognized as dates)
I.E. 04/01/2012 becomes 01/04/2012, this is presumably because the system has its regional settings set to "English (United States)", but I've made sure that the system's Regional Settings Short Date format is set to a custom value that matches the data in the spreadsheet ("dd/MM/yyyy"), and the problem only seems to occurs when the sheet is opened using the code above.
Any help would be very much appreciated. Thanks.
edit: The Operating System of the computer opening the files is Windows XP.
Local
- according to the docs "Local: True saves files against the language of Microsoft Excel (including control panel settings). False (default) saves files against the language of Visual Basic for Applications (VBA) (which is typically United States English.." - you could try passing true for that, even though it says 'Saves' not 'Opens'.. - stuartd