English 中文(简体)
“Solved” Query Excelday areas using theODBC Return
原标题:"Solved" Query Excel date fields using ODBC return null

我利用以下配置管理一个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.

感谢。

最佳回答

如果头8个行位为空白,Excel ODBC驾驶员将无法将该栏列为日列,因此试图获得所有其他行的日值不会成功。 在这个问题上没有任何办法,它不是一个与 Java有关的问题。

我不十分熟悉日本开发银行,但如果你重新要求一种办法,将实地的日期价值回去,尝试用这种方法来拉大面价值,然后将扼杀物按日价值(如果这项工作不算,则称回收浮动点值的方法,因为这一方法如何在内部储存Excel日期)。

或者,w更好的解决办法是:NOT使用Excel s ODBC驾驶员(这是臭名昭著的 b和有限的)和使用Patrice POI图书馆,而后者可以读到Excel的本土档案。 你们失去了 que糖,但是,通过活跃的囚室找到你的数据的简单 lo,就会 do。

问题回答

暂无回答




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签