diff --git a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php index 38c1c85..99d8563 100644 --- a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php +++ b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php @@ -24,6 +24,7 @@ class CellValueFormatter const XML_NODE_P = 'p'; const XML_NODE_S = 'text:s'; const XML_NODE_A = 'text:a'; + const XML_NODE_SPAN = 'text:span'; /** Definition of XML attribute used to parse data */ const XML_ATTRIBUTE_TYPE = 'office:value-type'; @@ -104,7 +105,7 @@ class CellValueFormatter $spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C); $numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1; $currentPValue .= str_repeat(' ', $numSpaces); - } else if ($childNode->nodeName === self::XML_NODE_A) { + } else if ($childNode->nodeName === self::XML_NODE_A || $childNode->nodeName === self::XML_NODE_SPAN) { $currentPValue .= $childNode->nodeValue; } } diff --git a/tests/Spout/Reader/ODS/ReaderTest.php b/tests/Spout/Reader/ODS/ReaderTest.php index 759d842..dee4164 100644 --- a/tests/Spout/Reader/ODS/ReaderTest.php +++ b/tests/Spout/Reader/ODS/ReaderTest.php @@ -468,6 +468,20 @@ class ReaderTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedRows, $allRows, 'Text in hyperlinks should be read'); } + /** + * @return void + */ + public function testReaderShouldReadInlineFontFormattingAsText() + { + $allRows = $this->getAllRowsForFile('sheet_with_inline_font_formatting.ods'); + + $expectedRows = [ + ['I am a yellow bird'] + ]; + + $this->assertEquals($expectedRows, $allRows, 'Text formatted inline should be read'); + } + /** * @param string $fileName * @param bool|void $shouldFormatDates diff --git a/tests/resources/ods/sheet_with_inline_font_formatting.ods b/tests/resources/ods/sheet_with_inline_font_formatting.ods new file mode 100644 index 0000000..60d4eee Binary files /dev/null and b/tests/resources/ods/sheet_with_inline_font_formatting.ods differ