update xlsx reader
This commit is contained in:
1 parent
7f26167be8
commit
f8baef148f
3 files changed
+44
-2
No files matched your search
@@ -23,6 +23,7 @@ class CellValueFormatter
|
||||
|
||||
/** Definition of XML nodes names used to parse data */
|
||||
const XML_NODE_VALUE = 'v';
|
||||
const XML_NODE_FORMULA = 'f';
|
||||
const XML_NODE_INLINE_STRING_VALUE = 't';
|
||||
|
||||
/** Definition of XML attributes used to parse data */
|
||||
@@ -107,6 +108,21 @@ class CellValueFormatter
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cell formula associated to the given XML node.
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @return string The formula associated with the cell
|
||||
*/
|
||||
public function extractNodeFormula($node)
|
||||
{
|
||||
// for cell types having a "f" tag containing the formula.
|
||||
// if not, the returned formula should be empty string.
|
||||
$vNode = $node->getElementsByTagName(self::XML_NODE_FORMULA)->item(0);
|
||||
|
||||
return ($vNode !== null) ? $vNode->nodeValue : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cell's string value from a node's nested value node
|
||||
*
|
||||
|
||||
@@ -359,7 +359,9 @@ class RowIterator implements IteratorInterface
|
||||
{
|
||||
try {
|
||||
$cellValue = $this->cellValueFormatter->extractAndFormatNodeValue($node);
|
||||
$cellFormula = $this->cellValueFormatter->extractNodeFormula($node);
|
||||
$cell = $this->entityFactory->createCell($cellValue);
|
||||
$cell->setFormula($cellFormula);
|
||||
} catch (InvalidValueException $exception) {
|
||||
$cell = $this->entityFactory->createCell($exception->getInvalidValue());
|
||||
$cell->setType(Cell::TYPE_ERROR);
|
||||
|
||||
Reference in new issue
Block a user