Use worksheet->getHighestColumn/Row for isFiltered
There may very well be a good reason the row/col attributes are loaded first. This is passing the test suite though and I think makes more sense than iterating over the Row/Col attrs to get the Col/Row isFiltered bool.
This commit is contained in:
parent
f366c0f257
commit
e1018e2330
|
@ -630,19 +630,6 @@ class Xlsx extends BaseReader
|
||||||
$docSheet->setSheetState((string) $eleSheet['state']);
|
$docSheet->setSheetState((string) $eleSheet['state']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($xmlSheet) {
|
|
||||||
if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) {
|
|
||||||
$sheetViews = new SheetViews($xmlSheet->sheetViews->sheetView, $docSheet);
|
|
||||||
$sheetViews->load();
|
|
||||||
}
|
|
||||||
|
|
||||||
$sheetViewOptions = new SheetViewOptions($docSheet, $xmlSheet);
|
|
||||||
$sheetViewOptions->load($this->getReadDataOnly());
|
|
||||||
|
|
||||||
(new ColumnAndRowAttributes($docSheet, $xmlSheet))
|
|
||||||
->load($this->getReadFilter(), $this->getReadDataOnly());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
|
if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
|
||||||
$cIndex = 1; // Cell Start from 1
|
$cIndex = 1; // Cell Start from 1
|
||||||
foreach ($xmlSheet->sheetData->row as $row) {
|
foreach ($xmlSheet->sheetData->row as $row) {
|
||||||
|
@ -756,6 +743,19 @@ class Xlsx extends BaseReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($xmlSheet) {
|
||||||
|
if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) {
|
||||||
|
$sheetViews = new SheetViews($xmlSheet->sheetViews->sheetView, $docSheet);
|
||||||
|
$sheetViews->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheetViewOptions = new SheetViewOptions($docSheet, $xmlSheet);
|
||||||
|
$sheetViewOptions->load($this->getReadDataOnly());
|
||||||
|
|
||||||
|
(new ColumnAndRowAttributes($docSheet, $xmlSheet))
|
||||||
|
->load($this->getReadFilter(), $this->getReadDataOnly());
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
|
if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
|
||||||
(new ConditionalStyles($docSheet, $xmlSheet, $dxfs))->load();
|
(new ConditionalStyles($docSheet, $xmlSheet, $dxfs))->load();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ColumnAndRowAttributes extends BaseParserClass
|
||||||
foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) {
|
foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) {
|
||||||
if (
|
if (
|
||||||
$readFilter === null ||
|
$readFilter === null ||
|
||||||
!$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)
|
!$this->isFilteredColumn($readFilter, $columnCoordinate)
|
||||||
) {
|
) {
|
||||||
if (!isset($columnsAttributesAreSet[$columnCoordinate])) {
|
if (!isset($columnsAttributesAreSet[$columnCoordinate])) {
|
||||||
$this->setColumnAttributes($columnCoordinate, $columnAttributes);
|
$this->setColumnAttributes($columnCoordinate, $columnAttributes);
|
||||||
|
@ -109,7 +109,7 @@ class ColumnAndRowAttributes extends BaseParserClass
|
||||||
foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) {
|
foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) {
|
||||||
if (
|
if (
|
||||||
$readFilter === null ||
|
$readFilter === null ||
|
||||||
!$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)
|
!$this->isFilteredRow($readFilter, $rowCoordinate)
|
||||||
) {
|
) {
|
||||||
if (!isset($rowsAttributesAreSet[$rowCoordinate])) {
|
if (!isset($rowsAttributesAreSet[$rowCoordinate])) {
|
||||||
$this->setRowAttributes($rowCoordinate, $rowAttributes);
|
$this->setRowAttributes($rowCoordinate, $rowAttributes);
|
||||||
|
@ -119,17 +119,13 @@ class ColumnAndRowAttributes extends BaseParserClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isFilteredColumn(IReadFilter $readFilter, $columnCoordinate, array $rowsAttributes)
|
private function isFilteredColumn(IReadFilter $readFilter, $columnCoordinate)
|
||||||
{
|
{
|
||||||
if (empty($rowAttributes)) {
|
for ($rowCoordinate = 1; $rowCoordinate <= $this->worksheet->getHighestRow(); $rowCoordinate++) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) {
|
|
||||||
if ($readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) {
|
if ($readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,17 +170,14 @@ class ColumnAndRowAttributes extends BaseParserClass
|
||||||
return $columnAttributes;
|
return $columnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isFilteredRow(IReadFilter $readFilter, $rowCoordinate, array $columnsAttributes)
|
private function isFilteredRow(IReadFilter $readFilter, $rowCoordinate)
|
||||||
{
|
{
|
||||||
if (empty($columnAttributes)) {
|
$lastColumnIndex = Coordinate::columnIndexFromString($this->worksheet->getHighestColumn());
|
||||||
return false;
|
for ($columnIndex = 1; $columnIndex <= $lastColumnIndex; $columnIndex++) {
|
||||||
}
|
if ($readFilter->readCell(Coordinate::stringFromColumnIndex($columnIndex), $rowCoordinate)) {
|
||||||
foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) {
|
|
||||||
if ($readFilter->readCell($columnCoordinate, $rowCoordinate, $this->worksheet->getTitle())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue