我想插入數據並使用ODBC連接從Excel中選擇數據。我已成功地連接到它:使用Microsoft Excel通過ODBC驅動程序與PHP
$dbh = new PDO("odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Dbq=$file_name", $username, $password);
不過,我不確定如何查詢Excel作爲有最小文檔此!我嘗試這樣的:
$query = "INSERT INTO $sheet ($cell) VALUES ($value)";
$result = $dbh->query($query);
但是,這會導致錯誤:
Array ([0] => 07002 [1] => -3010 [2] => [Microsoft][ODBC Excel Driver] The Microsoft Office Access database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly. (SQLExecute[-3010] at ext\pdo_odbc\odbc_stmt.c:254) [3] => 07002)
通過對象,希望他們的意思是一個Excel工作表?
感謝所有的幫助
您的工作簿中是否存在「Sheet1」,或者您是否正在寫入「Worksheet1」? – 2011-02-17 13:30:38
Sheet1確實存在,當我打開excel時,我可以看到第一張紙被命名爲「Sheet1」。 – Abs 2011-02-17 13:50:39