爲了維護一些陳舊的垃圾代碼,我在導入symfony命令時遇到了phpexcel的問題。從phpexcel的其他表中讀取公式
似乎庫無法正確計算出與活動工作表相同文檔的另一頁鏈接的公式。
我得到的錯誤是:
[PHPExcel_Calculation_Exception]
Price Template Map!B2 -> Invalid cell coordinate A
我的代碼是:
try {
$inputFileType = \PHPExcel_IOFactory::identify($filePath);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setLoadSheetsOnly(array($this->getListName(), 'Template Info'));
$objReader->setIncludeCharts(true);
$objPHPExcel = $objReader->load($filePath);
} catch (\Exception $e) {
throw new \Exception("Invalid file");
}
$sheet = $objPHPExcel->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$fieldsNumber = array();
$filterData = array();
$templateIdList = array();
for ($i = 1; $i <= $highestRow; $i++) {
$rowData = $sheet->rangeToArray('A' . $i . ':' . $highestColumn . $i, null, true, false);
$rowData = $rowData[0];
var_dump($rowData);
}
第一行與頭被正確讀取,但其餘的不是。
我的公式是:
=VLOOKUP(A18,'Template Info'!A:C,3,FALSE)"
不要猶豫,問我更多的信息,如果你需要它!
謝謝大家提前:)!
問題是rangeToArr第三個參數是一個布爾值,用於知道庫是否應該使用getCalculatedValue()或不使用getCalculatedValue()。它目前設置爲true。如果我將它設置爲false,我將以原始格式接收公式。 – Kern
爲什麼不設置爲true? –
它被設置爲true :) – Kern