From 77199c9877cb9b3992a5f835592a737720f8403a Mon Sep 17 00:00:00 2001 From: "azine.me" Date: Thu, 20 Apr 2017 22:42:04 +0200 Subject: [PATCH] Ods writer repects PreCalculateFormulas flag The OpenDocument Writer did not respect the "preCalculateFormulas" flag that can be set to speed up saving process, now it does. Closes #142 --- src/PhpSpreadsheet/Writer/Ods/Content.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index b8597028..bd5db3e3 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -224,10 +224,13 @@ class Content extends WriterPart throw new Exception('Writing of error not implemented yet.'); break; case DataType::TYPE_FORMULA: - try { - $formulaValue = $cell->getCalculatedValue(); - } catch (\Exception $e) { - $formulaValue = $cell->getValue(); + $formulaValue = $cell->getValue(); + if ($this->getParentWriter()->getPreCalculateFormulas()) { + try { + $formulaValue = $cell->getCalculatedValue(); + } catch (Exception $e) { + // don't do anything + } } $objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue()); if (is_numeric($formulaValue)) {