From d03ffd6776b1f0961ed5af7d8000b79e15df62e4 Mon Sep 17 00:00:00 2001 From: goncons Date: Sun, 6 Jul 2014 18:48:07 -0430 Subject: [PATCH] Open Document cell with not numeric formula Trying to write a Open Document with non numeric formula in a cell this exception was generated: "XMLWriter::writeAttribute() expects parameter 2 to be string, array given" The problem was that writer was using PHPExcel_Calculation::getInstance()->calculateCellValue($cell); instead of $cell->getCalculatedValue(); --- Classes/PHPExcel/Writer/OpenDocument/Content.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Writer/OpenDocument/Content.php b/Classes/PHPExcel/Writer/OpenDocument/Content.php index 932f2cae..65ee5ed4 100644 --- a/Classes/PHPExcel/Writer/OpenDocument/Content.php +++ b/Classes/PHPExcel/Writer/OpenDocument/Content.php @@ -205,12 +205,16 @@ class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_ case PHPExcel_Cell_DataType::TYPE_FORMULA: try { - $formula_value = PHPExcel_Calculation::getInstance()->calculateCellValue($cell); + $formula_value = $cell->getCalculatedValue(); } catch (Exception $e) { $formula_value = $cell->getValue(); } $objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue()); - $objWriter->writeAttribute('office:value-type', 'float'); + if (is_numeric($formula_value)) { + $objWriter->writeAttribute('office:value-type', 'float'); + } else { + $objWriter->writeAttribute('office:value-type', 'string'); + } $objWriter->writeAttribute('office:value', $formula_value); $objWriter->writeElement('text:p', $formula_value); break;