mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-31 04:28:51 +00:00
Modify toArray() method to use highest data row/column rather than highest row/column
This commit is contained in:
Generated
+505
-173
File diff suppressed because it is too large
Load Diff
@@ -3001,15 +3001,14 @@ class Worksheet implements IComparable
|
||||
$this->garbageCollect();
|
||||
|
||||
// Identify the range that we need to extract from the worksheet
|
||||
$maxCol = $this->getHighestColumn();
|
||||
$maxRow = $this->getHighestRow();
|
||||
$maxCell = $this->getHighestDataRowAndColumn();
|
||||
|
||||
if ($currentCellAddress !== null) {
|
||||
$this->getCell($currentCellAddress);
|
||||
}
|
||||
|
||||
// Return
|
||||
return $this->rangeToArray('A1:' . $maxCol . $maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||
return $this->rangeToArray('A1:' . $maxCell, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,10 +218,10 @@ class XlsxTest extends TestCase
|
||||
$reader = new Xlsx();
|
||||
$reader->setReadFilter(new OddColumnReadFilter());
|
||||
$data = $reader->load($filename)->getActiveSheet()->toArray();
|
||||
$ref = [1.0, null, 3.0, null, 5.0, null, 7.0, null, 9.0, null];
|
||||
$ref = [1, null, 3, null, 5, null, 7, null, 9];
|
||||
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
self::assertEquals($ref, \array_slice($data[$i], 0, 10, true));
|
||||
self::assertEquals($ref, \array_slice($data[$i], 0, 9, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user