【问题标题】:with php importing excel data into mysql using excelreader2.php使用 excelreader2.php 将 excel 数据导入 mysql
【发布时间】:2013-03-20 05:42:53
【问题描述】:

我必须将 excel 数据导入我的 mysql 数据库,但我面临“文件名 uploads/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();

    }

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

【问题讨论】:

  • 您对该文件有权限吗?在您的应用尝试访问该文件的同时,该文件没有在 Excel 中打开?
  • 错误提示..“文件不可读”..只需更改权限
  • 什么类型的权限以及如何更改它...???
  • bool is_readable ( string $filename )检查文件,如果文件不可读,尝试用bool chmod ( string $filename , int $mode )设置权限
  • 我仍然有同样的问题,首先尝试了所有建议...... :((

标签: php mysql excel


【解决方案1】:

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

您要么需要与 read them 不同的库,要么需要像 PHPExcel 这样可以读取这两种格式的库

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 2019-03-12
    相关资源
    最近更新 更多