0

第一次,我使用此代码更改静态文档值

$path = 'xtelcom.xlsx';
            $objReader = PHPExcel_IOFactory::createReader('Excel2007');
            $objReader->setReadDataOnly(true);
            $excel_import = $objReader->load($path);
            $excel_import->setActiveSheetIndex(0);
            $excel_import->getActiveSheet()->setCellValue('B1', '50');

            $objWriter = PHPExcel_IOFactory::createWriter($excel_import, 'Excel2007');
            $objWriter->save('new_calcule.xlsx');

并且文件'new_calcule.xlsx'对我的值没问题,但是当我尝试从某些单元格获取格式化值时,我的页面空白,死了,非常重要的excel文件很大,我需要 cyclicFormulaCount 才能工作我得到.

Fatal error: Uncaught exception 'PHPExcel_Calculation_Exception' with message 'Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Sheet1!F9 -> Cyclic Reference in Formula' in /home/xtelro/public_html/easyb.ro/ec/inc/Classes/PHPExcel/Cell.php:300 Stack trace: #0 /home/xtelro/public_html/easyb.ro/ec/inc/Classes/PHPExcel/Cell.php(201): PHPExcel_Cell->getCalculatedValue() #1 /home/xtelro/public_html/easyb.ro/ec/admin/imp.php(66): PHPExcel_Cell->getFormattedValue() #2 {main} thrown in /home/xtelro/public_html/easyb.ro/ec/inc/Classes/PHPExcel/Cell.php on line 300

include '../inc/Classes/PHPExcel/IOFactory.php';
            $objReader2 = PHPExcel_IOFactory::createReader('Excel2007');
            $excel_import2 = $objReader2->load('new_calcule.xlsx');
            $excel_import2->setActiveSheetIndex(0);
            PHPExcel_Calculation::getInstance($excel_import2)->cyclicFormulaCount = 10000;

            $figaro1 = $excel_import2->getActiveSheet()->getCell('K23')->getFormattedValue();
            echo 'Pret vechi:' . $figaro1;
            $figaro2 = $excel_import2->getActiveSheet()->getCell('L23')->getFormattedValue();
            echo 'Pret nou:' . $figaro2;
            $figaro3 = $excel_import2->getActiveSheet()->getCell('M23')->getFormattedValue();
            echo 'Pret minim admis:' . $figaro3;

必须显示回声,但我的脚本没有任何错误就死了,你能帮我解决和理解这个吗?谢谢!

4

0 回答 0