PHPExcel - Value from a Cell referencing to another Cell Did Not Obtained Properly

后端 未结 1 1329
灰色年华
灰色年华 2021-01-19 17:35

I\'m having this problem when I tried to extract information from excel files. Here\'s my situation, I have 34 Excel files which I received from my various users.

I\

1条回答
  •  不思量自难忘°
    2021-01-19 18:28

    PHPExcel holds a calculation cache as well, and this is not cleared when you unset a workbook: it has to be cleared manually using:

    PHPExcel_Calculation::flushInstance();
    

    or

    PHPExcel_Calculation::getInstance()->clearCalculationCache();
    

    You can also disable calculation caching completely (although this may slow things down if you have a lot of formulae that reference cells containing other formulae) using:

    PHPExcel_Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
    

    before you start processing your files

    This is because currently PHPExcel uses a singleton for the calculation engine. It is in the roadmap to switch to using a multiton pattern later this year, which will effectively maintain a separate cache for each workbook, alleviating this problem.

    EDIT

    Note that simply unsetting $objPHPExcel does not work. You need to detach the worksheets before unsetting $objPHPExcel.

    $objPHPExcel->disconnectWorksheets();
    unset($objPHPExcel);
    

    as described in section 4.3 of the Developer Documentation. And this is the point where you should also add the PHPExcel_Calculation::flushInstance();

    0 讨论(0)
提交回复
热议问题