与PHP使用excelreader2.php将excel数据导入到mysql

我必须导入一个Excel数据到我的MySQL数据库,但我面临“ 文件名上传/ dd.xlsx不可读 ”。 我不知道什么是错误,为什么我的Excel表不可读… excelreader2.php的代码是。

function read($sFileName) { $res = $this->_ole->read($sFileName); // oops, something goes wrong (Darko Miljanovic) if($res === false) { // check error code if($this->_ole->error == 1) { // bad file die('The filename ' . $sFileName . ' is not readable'); } // check other error codes here (eg bad fileformat, etc...) } $this->data = $this->_ole->getWorkBook(); $this->_parse(); } 

我做了所有可能的结帐….可以任何人理清这….

一个xlsx文件不是一个OLE文件。 xls文件是OLE BIFF文件,标准格式直到Excel 2003; xlsx文件是为Excel 2007引入的OfficeOpenXML格式。

您可能需要使用不同的库来读取它们 ,或者使用PHPExcel等可以读取这两种格式的库