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
This commit is contained in:
azine.me 2017-04-20 22:42:04 +02:00 committed by Adrien Crivelli
parent 4c42afe7b8
commit 77199c9877
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
1 changed files with 7 additions and 4 deletions

View File

@ -224,10 +224,13 @@ class Content extends WriterPart
throw new Exception('Writing of error not implemented yet.'); throw new Exception('Writing of error not implemented yet.');
break; break;
case DataType::TYPE_FORMULA: case DataType::TYPE_FORMULA:
$formulaValue = $cell->getValue();
if ($this->getParentWriter()->getPreCalculateFormulas()) {
try { try {
$formulaValue = $cell->getCalculatedValue(); $formulaValue = $cell->getCalculatedValue();
} catch (\Exception $e) { } catch (Exception $e) {
$formulaValue = $cell->getValue(); // don't do anything
}
} }
$objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue()); $objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue());
if (is_numeric($formulaValue)) { if (is_numeric($formulaValue)) {