phpexcel在linux系統報錯如何解決

來源:互聯網
上載者:User
最近有個tp3.2的項目遷移到linux系統上了,突然有天發現原本在win server 2008上運行沒問題的excel匯出功能在新的系統上不能使用了。報錯如下:

說是1762行有問題,找到這個檔案的代碼看看:

/**     * Get an instance of this class     *     * @access  public     * @param   PHPExcel $workbook  Injected workbook for working with a PHPExcel object,     *                                  or NULL to create a standalone claculation engine     * @return PHPExcel_Calculation     */    public static function getInstance(PHPExcel $workbook = NULL) {        if ($workbook !== NULL) {            if (isset(self::$_workbookSets[$workbook->getID()])) {                return self::$_workbookSets[$workbook->getID()];            }            return new PHPExcel_Calculation($workbook);        }        if (!isset(self::$_instance) || (self::$_instance === NULL)) {            self::$_instance = new PHPExcel_Calculation();        }        return self::$_instance;    }   //  function getInstance()

這個函數getInstance(PHPExcel $workbook = NULL)
發現這個函數 定義的時候多了個PHPExcel ,我試著把它刪除,上傳,測試,又報錯了:

這次是1721行,然後再次找到這個位置的檔案刪除 PHPExcel這個東東,然後繼續上傳,測試,後面大多數錯誤都是這種,刪掉函數定義時的PHPExcel即可,但是錯誤一個接一個,這是需要替換的檔案:

這個地方要加個空格,這樣才不會替換錯誤,好了,繼續上傳測試.

然後就這樣了…..當時內心是崩潰的…
繼續找問題吧,在測試php檔案裡面輸出變數進行測試。

PHPExcel\PHPExcel\Calculation\Functions.php  下面這個檔案,中有個 **TYPE**函數,將其中的break去掉,上傳,ok了/**     * TYPE     *     * Returns a number that identifies the type of a value     *     * @param   value       The value you want tested     * @return  number      N converts values listed in the following table     *      If value is or refers to N returns     *      A number            1     *      Text                2     *      Logical Value       4     *      An error value      16     *      Array or Matrix     64     */    public static function TYPE($value = NULL) {        $value= self::flattenArrayIndexed($value);        if (is_array($value) && (count($value) > 1)) {            $a = array_keys($value);            $a = array_pop($a);            //  Range of cells is an error            if (self::isCellValue($a)) {                return 16;            //  Test for Matrix            } elseif (self::isMatrixValue($a)) {                return 64;            }        } elseif(empty($value)) {            //  Empty Cell            return 1;        }        $value= self::flattenSingleValue($value);        if (($value === NULL) || (is_float($value)) || (is_int($value))) {                return 1;        } elseif(is_bool($value)) {                return 4;        } elseif(is_array($value)) {                return 64;                break;        } elseif(is_string($value)) {            //  Errors            if ((strlen($value) > 0) && ($value{0} == '#')) {                return 16;            }            return 2;        }        return 0;    }   //  function TYPE()

這是完整流程,線上系統用的是centos7,php是也是7。這個估計是不相容造成的,也沒有再深一步研究了,畢竟其實有新的excel外掛程式了,要不是,有太多代碼需要修改,估計我直接換外掛程式了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.