Search code examples
phpspreadsheet

Cannot set cell value in Phpspreadsheet


So this is very similar to ticket phpspreadsheet setCellValue is not writing however I cannot set the cell value for XLSX or ODS files at all in Phpspreadsheet (ODS files can crash explorer in my experience). I have the following function which worked fine in Phpexcel and still works fine for XLS but as I say - not XLSX or ODS. I've tried 2 setting methods - both have the same results. I don't get any error but the browser simply exits with "This site can’t be reached". I'm running LAMP and Ubuntu. Why is this not working?

public function setCell($ref,$value){
    //$this->active_sheet->setCellValue($ref,$value);
    $this->active_sheet->fromArray(array($value),null,$ref);        
}

Solution

  • So after a lot of investigation - this issue is the same bug as reported here: https://github.com/PHPOffice/PHPExcel/issues/846. It turns out running $writer->setPreCalculateFormulas(false); before outputting with save() fixed this issue.