diff --git a/src/Spout/Reader/XLSX.php b/src/Spout/Reader/XLSX.php
index b0a66d1..adb9544 100644
--- a/src/Spout/Reader/XLSX.php
+++ b/src/Spout/Reader/XLSX.php
@@ -206,13 +206,25 @@ class XLSX extends AbstractReader
$currentColumnIndex = CellHelper::getColumnIndexFromCellIndex($currentCellIndex);
$node = $this->xmlReader->expand();
+ $hasInlineString = ($this->xmlReader->getAttribute('t') === 'inlineStr');
$hasSharedString = ($this->xmlReader->getAttribute('t') === 's');
- if ($hasSharedString) {
- $sharedStringIndex = intval($node->nodeValue);
+
+ if ($hasInlineString) {
+ // inline strings are formatted this way:
+ // [INLINE_STRING]
+ $tNode = $node->getElementsByTagName('t')->item(0);
+ $rowData[$currentColumnIndex] = trim($tNode->nodeValue);
+ } else if ($hasSharedString) {
+ // shared strings are formatted this way:
+ // [SHARED_STRING_INDEX]
+ $vNode = $node->getElementsByTagName('v')->item(0);
+ $sharedStringIndex = intval($vNode->nodeValue);
$rowData[$currentColumnIndex] = $this->sharedStringsHelper->getStringAtIndex($sharedStringIndex);
} else {
- // for inline strings or numbers, just get the value
- $rowData[$currentColumnIndex] = trim($node->nodeValue);
+ // other values are formatted this way:
+ // [VALUE]
+ $vNode = $node->getElementsByTagName('v')->item(0);
+ $rowData[$currentColumnIndex] = intval($vNode->nodeValue);
}
} else if ($this->xmlReader->nodeType == \XMLReader::END_ELEMENT && $this->xmlReader->name === 'row') {
// End of the row description
diff --git a/tests/Spout/Reader/XLSXTest.php b/tests/Spout/Reader/XLSXTest.php
index 9a214f2..24aa89c 100644
--- a/tests/Spout/Reader/XLSXTest.php
+++ b/tests/Spout/Reader/XLSXTest.php
@@ -245,6 +245,21 @@ class XLSXTest extends \PHPUnit_Framework_TestCase
$this->assertEquals([], $allRows, 'Sheet with no cells should be correctly processed.');
}
+ /**
+ * @return void
+ */
+ public function testReadShouldSkipFormulas()
+ {
+ $allRows = $this->getAllRowsForFile('sheet_with_formulas.xlsx');
+
+ $expectedRows = [
+ ['val1', 'val2', 'total1', 'total2'],
+ [10, 20, 30, 21],
+ [11, 21, 32, 41],
+ ];
+ $this->assertEquals($expectedRows, $allRows);
+ }
+
/**
* @param string $fileName
* @return array All the read rows the given file
diff --git a/tests/resources/xlsx/sheet_with_formulas.xlsx b/tests/resources/xlsx/sheet_with_formulas.xlsx
new file mode 100644
index 0000000..99975ae
Binary files /dev/null and b/tests/resources/xlsx/sheet_with_formulas.xlsx differ