This commit is contained in:
madflow 2016-05-20 18:32:47 +02:00 committed by Adrien Loison
parent b4724906c4
commit 2d923c7e46
3 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,7 @@ class CellValueFormatter
/** Definition of XML nodes names used to parse data */
const XML_NODE_P = 'p';
const XML_NODE_S = 'text:s';
const XML_NODE_A = 'text:a';
/** Definition of XML attribute used to parse data */
const XML_ATTRIBUTE_TYPE = 'office:value-type';
@ -98,6 +99,8 @@ 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) {
$currentPValue .= $childNode->nodeValue;
}
}

View File

@ -436,6 +436,23 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedRows, $allRows, 'Cell values should not be trimmed');
}
/**
* https://github.com/box/spout/issues/218
* @return void
*/
public function testReaderShouldReadTextInHyperlinks()
{
$allRows = $this->getAllRowsForFile('sheet_with_hyperlinks.ods');
$expectedRows = [
['email', 'text'],
['1@example.com', 'text'],
['2@example.com', 'text and https://github.com/box/spout/issues/218 and text'],
];
$this->assertEquals($expectedRows, $allRows, 'Text in hyperlinks should be read');
}
/**
* @param string $fileName
* @return array All the read rows the given file

Binary file not shown.