How to automatically read in calculated values with PHPExcel?

前端 未结 5 1969
广开言路
广开言路 2020-12-05 06:15

I have the following Excel file:

\"alt

I read it in by looping

5条回答
  •  无人及你
    2020-12-05 06:57

    If you are unsure about the content of a cell (value or formula included), I recommend you to primarily do a check if the cell has a formula and then copy - paste accordingly. getOldCalculatedValue() is very helpful in this case. Here is an example of that:

    $code = $sheet->getCell('A'.$y)->getValue();
    if(strstr($code,'=')==true)
    {
        $code = $sheet->getCell('A'.$y)->getOldCalculatedValue();
    }
    $objPHPExcel4->setActiveSheetIndex(0)
                 ->setCellValue('A'.$l, $code);
    

    For large data sets, getCalculatedValue() function is really cumbersome and lots of memory will be required to perform correctly.

提交回复
热议问题