@@ -77,6 +77,9 @@ public function load(?IReadFilter $readFilter = null, bool $readDataOnly = false
77
77
if ($ this ->worksheetXml === null ) {
78
78
return ;
79
79
}
80
+ if ($ readFilter !== null && $ readFilter ::class === DefaultReadFilter::class) {
81
+ $ readFilter = null ;
82
+ }
80
83
81
84
$ columnsAttributes = [];
82
85
$ rowsAttributes = [];
@@ -85,11 +88,7 @@ public function load(?IReadFilter $readFilter = null, bool $readDataOnly = false
85
88
}
86
89
87
90
if ($ this ->worksheetXml ->sheetData && $ this ->worksheetXml ->sheetData ->row ) {
88
- $ rowsAttributes = $ this ->readRowAttributes ($ this ->worksheetXml ->sheetData ->row , $ readDataOnly , $ ignoreRowsWithNoCells );
89
- }
90
-
91
- if ($ readFilter !== null && $ readFilter ::class === DefaultReadFilter::class) {
92
- $ readFilter = null ;
91
+ $ rowsAttributes = $ this ->readRowAttributes ($ this ->worksheetXml ->sheetData ->row , $ readDataOnly , $ ignoreRowsWithNoCells , $ readFilter !== null );
93
92
}
94
93
95
94
// set columns/rows attributes
@@ -123,12 +122,12 @@ public function load(?IReadFilter $readFilter = null, bool $readDataOnly = false
123
122
private function isFilteredColumn (IReadFilter $ readFilter , string $ columnCoordinate , array $ rowsAttributes ): bool
124
123
{
125
124
foreach ($ rowsAttributes as $ rowCoordinate => $ rowAttributes ) {
126
- if (! $ readFilter ->readCell ($ columnCoordinate , $ rowCoordinate , $ this ->worksheet ->getTitle ())) {
127
- return true ;
125
+ if ($ readFilter ->readCell ($ columnCoordinate , $ rowCoordinate , $ this ->worksheet ->getTitle ())) {
126
+ return false ;
128
127
}
129
128
}
130
129
131
- return false ;
130
+ return true ;
132
131
}
133
132
134
133
private function readColumnAttributes (SimpleXMLElement $ worksheetCols , bool $ readDataOnly ): array
@@ -189,27 +188,31 @@ private function isFilteredRow(IReadFilter $readFilter, int $rowCoordinate, arra
189
188
return false ;
190
189
}
191
190
192
- private function readRowAttributes (SimpleXMLElement $ worksheetRow , bool $ readDataOnly , bool $ ignoreRowsWithNoCells ): array
191
+ private function readRowAttributes (SimpleXMLElement $ worksheetRow , bool $ readDataOnly , bool $ ignoreRowsWithNoCells, bool $ readFilterIsNotNull ): array
193
192
{
194
193
$ rowAttributes = [];
195
194
196
195
foreach ($ worksheetRow as $ rowx ) {
197
196
$ row = $ rowx ->attributes ();
198
197
if ($ row !== null && (!$ ignoreRowsWithNoCells || isset ($ rowx ->c ))) {
198
+ $ rowIndex = (int ) $ row ['r ' ];
199
199
if (isset ($ row ['ht ' ]) && !$ readDataOnly ) {
200
- $ rowAttributes [( int ) $ row [ ' r ' ] ]['rowHeight ' ] = (float ) $ row ['ht ' ];
200
+ $ rowAttributes [$ rowIndex ]['rowHeight ' ] = (float ) $ row ['ht ' ];
201
201
}
202
202
if (isset ($ row ['hidden ' ]) && self ::boolean ($ row ['hidden ' ])) {
203
- $ rowAttributes [( int ) $ row [ ' r ' ] ]['visible ' ] = false ;
203
+ $ rowAttributes [$ rowIndex ]['visible ' ] = false ;
204
204
}
205
205
if (isset ($ row ['collapsed ' ]) && self ::boolean ($ row ['collapsed ' ])) {
206
- $ rowAttributes [( int ) $ row [ ' r ' ] ]['collapsed ' ] = true ;
206
+ $ rowAttributes [$ rowIndex ]['collapsed ' ] = true ;
207
207
}
208
208
if (isset ($ row ['outlineLevel ' ]) && (int ) $ row ['outlineLevel ' ] > 0 ) {
209
- $ rowAttributes [( int ) $ row [ ' r ' ] ]['outlineLevel ' ] = (int ) $ row ['outlineLevel ' ];
209
+ $ rowAttributes [$ rowIndex ]['outlineLevel ' ] = (int ) $ row ['outlineLevel ' ];
210
210
}
211
211
if (isset ($ row ['s ' ]) && !$ readDataOnly ) {
212
- $ rowAttributes [(int ) $ row ['r ' ]]['xfIndex ' ] = (int ) $ row ['s ' ];
212
+ $ rowAttributes [$ rowIndex ]['xfIndex ' ] = (int ) $ row ['s ' ];
213
+ }
214
+ if ($ readFilterIsNotNull && empty ($ rowAttributes [$ rowIndex ])) {
215
+ $ rowAttributes [$ rowIndex ]['exists ' ] = true ;
213
216
}
214
217
}
215
218
}
0 commit comments