我利用以下配置管理一个java方案,从外壳中提取数据。 其中一些栏目有时间范围的数据。
- Platform: Win 7 (x64)
- ODBC: Excel (x32) [via Office 2010]; rows to scan = 8
- Excel schema: "some fields", "date field 1", "date field 2", "date field 3", "other fields"
- Date format shown in excel: dd/mm/yyyy HH:MM
- Java 1.6
- JDBC/ODBC driver: sun.jdbc.odbc.JdbcOdbcDriver
我尝试了以下(简化)查询,以提取数据:
www.un.org/Depts/DGACM/index_spanish.htm
SlectT [field 1], [date field 1], [date field 2] from [Sheet1$] where [field 1] = “sample Value
I m sure the "date field 2" contains valid date values (but emptied for the first 20 rows) and the java program always return null for that column.
So, my question is will the empty value of [date field 2] of initial rows, says 8 rows, affect behavior of the JDBC/ODBC? If yes, how to avoid it (without sorting the data in the excel file)?
-- Edit -- Actually, I m asking if the empty values of that field in the first few rows (say 8) will make the driver fail to extract the value of that column (even if the subsequent rows contain valid value). I m also confused if it is implementation-specific that the driver will simply refuse to extract that field, returning null for all conditions, and even not to attempt to treat the column as string-type or return empty string (instead of NULL)
-- Edit -- Referring to the information in this KB: http://support.microsoft.com/kb/141284
The empty value of the first few rows in [date field 2] will make the ODBC driver return NULL under all conditions. So the root cause is found and what next is to find alternative JDBC driver for Excel files.
感谢。