PHPExcel excel读取是不工作的一些计算单元格


PHPExcel excel read is not working for some cells with calculation

我使用PHPExcel库来读取Codeigniter项目中的excel文件。它不读取一些单元格与计算。它显示为#VALUE!,但一些计算值是在同一个excel表格中读取的。这些细胞怎么了?

有下列计算的单元格没有读取

=+D109*1000     
=+B16/B13
=+D23/$D$109 

有下列计算的单元格正在读取

=+B10-B11
=+C10-C11

但是所有单元格都在读取某些excel工作表。这个问题出现在xlsx格式

这是我的代码

$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$this->excel = $objReader->load($path);
$this->excel->setActiveSheetIndex($sheet);
$data = $this->excel->getActiveSheet()->toArray(null, true, true, true);
print_r($data);

我查了谷歌。getCalculatedValue()应用于读取计算值。但我不能一个一个地用。它是否有一个方法来读取所有的表作为数组?

How ever i check some cell with following way

$this->excel->getActiveSheet()->getCell('B18')->getCalculatedValue() // return #VALUE!
$this->excel->getActiveSheet()->getCell('B18')->getOldCalculatedValue() //return 0.4211

我如何使用旧的计算值使用toArray?

最后我得到旧getOldCalculatedValue使用循环。

$data = $this->excel->getActiveSheet()->toArray(null, true, true, true);
//This code add for some calculated cells were not reading in xlsx format
foreach ($data as $no => $row) {
    foreach ($row as $key => $value) {
        if (isset($value) && $value == '#VALUE!') {
            $data[$no][$key] = $this->excel->getActiveSheet()->getCell($key.$no)->getOldCalculatedValue();
        }
    }
}