最近有個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插件了,要不是,有太多代碼需要修改,估計我直接換插件了。
相關推薦: