Commit 3c8ff6e0 authored by claudiu.cristea's avatar claudiu.cristea Committed by claudiu.cristea

Issue #2914156 by claudiu.cristea, woutgg: Wrong data returned for columns...

Issue #2914156 by claudiu.cristea, woutgg: Wrong data returned for columns next to columns with empty header
parent f9a581b1
......@@ -255,6 +255,7 @@ class SpreadsheetIterator implements SpreadsheetIteratorInterface {
for ($col_index = $first_col_index; $col_index <= $this->getColumnsCount(); ++$col_index) {
$col_letter = Coordinate::stringFromColumnIndex($col_index);
if ($header_row = $this->getHeaderRow()) {
$value = '';
if ($cell = $this->getWorksheet()->getCell("$col_letter$header_row", FALSE)) {
$value = trim($cell->getValue());
if (isset($this->cache['headers'][$value])) {
......
......@@ -50,7 +50,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
*/
public function testRowsAndColumnsCount() {
$this->assertEquals(5, $this->iterator->getRowsCount());
$this->assertEquals(5, $this->iterator->getColumnsCount());
$this->assertEquals(7, $this->iterator->getColumnsCount());
}
/**
......@@ -84,13 +84,13 @@ class SpreadsheetIteratorTest extends UnitTestCase {
// A valid origin.
['B3', FALSE],
// Column out of bounds.
['F3', TRUE],
['H3', TRUE],
// Row out of bounds.
['E6', TRUE],
// Both, row and column, out of bounds.
['F6', TRUE],
['H6', TRUE],
// The maximum valid value.
['E5', FALSE],
['G5', FALSE],
];
}
......@@ -103,10 +103,11 @@ class SpreadsheetIteratorTest extends UnitTestCase {
'column c' => 'C',
'column d' => 'D',
'column e' => 'E',
'column g' => 'G',
];
$this->assertSame($cols, $this->iterator->getHeaders());
// Check headers when there's no header row.
// Check headers when there's no header row. All columns should be used.
$config = $this->iterator->getConfiguration();
unset($config['header_row']);
$this->iterator->setConfiguration($config);
......@@ -115,6 +116,8 @@ class SpreadsheetIteratorTest extends UnitTestCase {
'C' => 'C',
'D' => 'D',
'E' => 'E',
'F' => 'F',
'G' => 'G',
], $this->iterator->getHeaders());
// Check duplicate headers.
......@@ -190,6 +193,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
'column c' => 'cell c0',
'column d' => 'cell d0',
'column e' => 'cell e0',
'column g' => 'cell g0',
], $this->iterator->current());
// Use different primary keys.
......@@ -238,21 +242,30 @@ class SpreadsheetIteratorTest extends UnitTestCase {
->setCellValue('C2', 'column c')
->setCellValue('D2', 'column d')
->setCellValue('E2', 'column e')
// Column 'F' is missing the header value.
->setCellValue('G2', 'column g')
// Data row with index 0 starts on row 3.
->setCellValue('B3', 'cell b0')
->setCellValue('C3', 'cell c0')
->setCellValue('D3', 'cell d0')
->setCellValue('E3', 'cell e0')
->setCellValue('F3', 'cell f0')
->setCellValue('G3', 'cell g0')
// Data row with index 1.
->setCellValue('B4', 'cell b1')
->setCellValue('C4', 'cell c1')
->setCellValue('D4', 'cell d1')
->setCellValue('E4', 'cell e1')
->setCellValue('F4', 'cell f1')
->setCellValue('G4', 'cell g1')
// Data row with index 2.
->setCellValue('B5', 'cell b2')
->setCellValue('C5', 'cell c2')
->setCellValue('D5', 'cell d2')
->setCellValue('E5', 'cell e2');
->setCellValue('E5', 'cell e2')
->setCellValue('F5', 'cell f2')
->setCellValue('G5', 'cell g2');
}
return $this->worksheet;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment