首页 > 解决方案 > 无法在 Phpspreadsheet 中设置单元格值

问题描述

因此,这与票据phpspreadsheet setCellValue is not writing非常相似,但是我根本无法在 Phpspreadsheet 中设置 XLSX 或 ODS 文件的单元格值(根据我的经验,ODS 文件可能会使资源管理器崩溃)。我有以下功能,它在 Phpexcel 中运行良好,并且仍然适用于 XLS,但正如我所说 - 不是 XLSX 或 ODS。我尝试了 2 种设置方法 - 都具有相同的结果。我没有收到任何错误,但浏览器只是以“无法访问此站点”退出。我正在运行 LAMP 和 Ubuntu。为什么这不起作用?

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

标签: phpspreadsheet

解决方案


因此,经过大量调查 - 此问题与此处报告的错误相同:https ://github.com/PHPOffice/PHPExcel/issues/846 。事实证明,$writer->setPreCalculateFormulas(false);在使用 save() 输出之前运行修复了这个问题。


推荐阅读