
這是我的程式碼:
<?php
$connect = odbc_connect('Test','EWF','EWF');
$query = "SELECT * FROM [Sheet1$];";
$result = odbc_exec($connect,$query);
$row = odbc_fetch_array($result);
if (!$row){
$test = odbc_result($row,'Column');
echo $test;
}
出現空白頁但沒有資料? ?>
答案1
如果這是您正在使用的實際連接字串,那麼它是錯誤的。您需要聲明您正在使用的驅動程序,然後為驅動程式提供它期望的參數。這是一個例子:
$excelFile = "your file name here.xls";
$excelDir = "path\to\that\file\";
odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', '');
PHP 文檔: https://www.php.net/manual/en/function.odbc-connect.php