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

时间:2013-03-20 05:42:54

标签: php mysql excel

我必须将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();

    }

我做了所有可能的结账....任何人都可以解决这个....

1 个答案:

答案 0 :(得分:0)

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

您需要使用不同的库read them,或者PHPExcel等可以读取这两种格式的库