@@ -85,8 +85,13 @@ public function parse(Cell $cell): string
85
85
{
86
86
$ this ->getTableStructure ($ cell );
87
87
$ cellRange = ($ this ->isRowReference ()) ? $ this ->getRowReference ($ cell ) : $ this ->getColumnReference ();
88
+ $ sheetName = '' ;
89
+ $ worksheet = $ this ->table ->getWorksheet ();
90
+ if ($ worksheet !== null && $ worksheet !== $ cell ->getWorksheet ()) {
91
+ $ sheetName = "' " . $ worksheet ->getTitle () . "'! " ;
92
+ }
88
93
89
- return $ cellRange ;
94
+ return $ sheetName . $ cellRange ;
90
95
}
91
96
92
97
private function isRowReference (): bool
@@ -115,7 +120,12 @@ private function getTableStructure(Cell $cell): void
115
120
$ this ->totalsRow = ($ this ->table ->getShowTotalsRow ()) ? (int ) $ tableRange [1 ][1 ] : null ;
116
121
$ this ->lastDataRow = ($ this ->table ->getShowTotalsRow ()) ? (int ) $ tableRange [1 ][1 ] - 1 : $ tableRange [1 ][1 ];
117
122
118
- $ this ->columns = $ this ->getColumns ($ cell , $ tableRange );
123
+ $ cellParam = $ cell ;
124
+ $ worksheet = $ this ->table ->getWorksheet ();
125
+ if ($ worksheet !== null && $ worksheet !== $ cell ->getWorksheet ()) {
126
+ $ cellParam = $ worksheet ->getCell ('A1 ' );
127
+ }
128
+ $ this ->columns = $ this ->getColumns ($ cellParam , $ tableRange );
119
129
}
120
130
121
131
/**
@@ -161,10 +171,12 @@ private function findTableFromOtherSheets(Cell $cell): ?Table
161
171
{
162
172
$ spreadsheet = $ cell ->getWorksheet ()->getParent ();
163
173
164
- foreach ($ spreadsheet ->getAllSheets () as $ sheet ) {
165
- $ table = $ sheet ->getTableByName ($ this ->tableName );
166
- if (null !== $ table ) {
167
- return $ table ;
174
+ if ($ spreadsheet !== null ) {
175
+ foreach ($ spreadsheet ->getAllSheets () as $ sheet ) {
176
+ $ table = $ sheet ->getTableByName ($ this ->tableName );
177
+ if (null !== $ table ) {
178
+ return $ table ;
179
+ }
168
180
}
169
181
}
170
182
@@ -342,7 +354,7 @@ private function getColumnsForColumnReference(string $reference, int $startRow,
342
354
{
343
355
$ columnsSelected = false ;
344
356
foreach ($ this ->columns as $ columnId => $ columnName ) {
345
- $ columnName = str_replace ("\u{a0}" , ' ' , $ columnName );
357
+ $ columnName = str_replace ("\u{a0}" , ' ' , $ columnName ?? '' );
346
358
$ cellFrom = "{$ columnId }{$ startRow }" ;
347
359
$ cellTo = "{$ columnId }{$ endRow }" ;
348
360
$ cellReference = ($ cellFrom === $ cellTo ) ? $ cellFrom : "{$ cellFrom }: {$ cellTo }" ;
0 commit comments