I just recently encountered a problem that could happen again sometime in the future regarding the date system flag in Excel at Tools / Options / Calculation / 1904 date system.
Background: Excel allows two date offset systems that are 1462 days apart. The Most common is the default 1900 date system. The other for 1904 originated on the Mac back in the 1980s and is likely used only by some Mac users. Each day was assigned its own sequential number, but at different starting points for each system. Naturally, Excel has multiple layers of formatting that hides this behavior "under the hood" so most users don't know about it.
Description of the differences between the 1900 date system and the 1904 date system in Excel
So the dilemma was that a spreadsheet was submitted and all the dates were 4 years off and the mystery was due to the conflicting date systems. Now we are concerned that other users may submit similarly configured spreadsheets and we want to be able to identify those files up front so erroneous dates are not saved and propagated, perhaps not being detected for days, months or longer.
Of course, we could always restrict submissions to CSV delimited text files, but we all know that won't happen, spreadsheets are simply too much of a common standard.
Clearly, the setting is saved in the file, but we were unable to identify the flag by examining the data collections in ADO. (We use ADO rather than IMPORT FROM or APPEND FROM for several reasons, one of them being that VFP SP1 can't read some of the newest Excel 2007 formats such as XLSX. I haven't installed SP2 so I don't yet know if it can read them natively.)
I did an internet search and didn't find any help for how to locate that flag. I searched two otherwise identical Excel 2003 spreadsheets and found that byte 765 seems to be the location of that flag.
Questions:
Is it always in the same location for all versions of Excel? I'm just not sure that every version of Excel will have this flag in the same location.
Does anyone know another or better way to identify this date system flag?
Does VFP SP2 read the newest Excel 2007 formats natively?
Background: Excel allows two date offset systems that are 1462 days apart. The Most common is the default 1900 date system. The other for 1904 originated on the Mac back in the 1980s and is likely used only by some Mac users. Each day was assigned its own sequential number, but at different starting points for each system. Naturally, Excel has multiple layers of formatting that hides this behavior "under the hood" so most users don't know about it.
Description of the differences between the 1900 date system and the 1904 date system in Excel
So the dilemma was that a spreadsheet was submitted and all the dates were 4 years off and the mystery was due to the conflicting date systems. Now we are concerned that other users may submit similarly configured spreadsheets and we want to be able to identify those files up front so erroneous dates are not saved and propagated, perhaps not being detected for days, months or longer.
Of course, we could always restrict submissions to CSV delimited text files, but we all know that won't happen, spreadsheets are simply too much of a common standard.
Clearly, the setting is saved in the file, but we were unable to identify the flag by examining the data collections in ADO. (We use ADO rather than IMPORT FROM or APPEND FROM for several reasons, one of them being that VFP SP1 can't read some of the newest Excel 2007 formats such as XLSX. I haven't installed SP2 so I don't yet know if it can read them natively.)
Code:
objExcConStr.ConnectionString = [Provider=Microsoft.ACE.OLEDB.12.0;Data Source=]+mySpreadSheet+[;Extended Properties='Excel 12.0;HDR=No;IMEX=1']
I did an internet search and didn't find any help for how to locate that flag. I searched two otherwise identical Excel 2003 spreadsheets and found that byte 765 seems to be the location of that flag.
Questions:
Is it always in the same location for all versions of Excel? I'm just not sure that every version of Excel will have this flag in the same location.
Does anyone know another or better way to identify this date system flag?
Does VFP SP2 read the newest Excel 2007 formats natively?