From b27412d00ff498319814c8c2d297f1400b35074c Mon Sep 17 00:00:00 2001 From: ArteQ Date: Mon, 12 Feb 2018 18:31:34 +0100 Subject: [PATCH] calculate cell formulas by default The 'setPreCalculateFormulas(true)' is needed to save the file with calculated forumulas. Without it if you have cell with formula ex. '=A1+A2' or `=SUM(A1:A2)' the result will be always zero until you reenter/recalculate the cell value once opened in Excel. Took me some time to figure this out, I belive it's the desired behavior for 99% developers who use any kind of formulas in generated spreadsheet so I'd make turned on by default. --- View/Helper/PhpExcelHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/View/Helper/PhpExcelHelper.php b/View/Helper/PhpExcelHelper.php index a199455..ad12850 100644 --- a/View/Helper/PhpExcelHelper.php +++ b/View/Helper/PhpExcelHelper.php @@ -338,6 +338,7 @@ public function output($filename = 'export.xlsx', $writer = 'Excel2007') { // writer $objWriter = $this->getWriter($writer); + $objWriter->setPreCalculateFormulas(true); $objWriter->save('php://output'); exit;