File tree 1 file changed +18
-0
lines changed
src/PhpSpreadsheet/Calculation/Engine/Operands 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -146,13 +146,31 @@ private function getTableByName(Cell $cell): Table
146
146
{
147
147
$ table = $ cell ->getWorksheet ()->getTableByName ($ this ->tableName );
148
148
149
+ if (!$ table ) {
150
+ $ table = $ this ->findTableFromOtherSheets ($ cell );
151
+ }
152
+
149
153
if ($ table === null ) {
150
154
throw new Exception ("Table {$ this ->tableName } for Structured Reference cannot be located " );
151
155
}
152
156
153
157
return $ table ;
154
158
}
155
159
160
+ private function findTableFromOtherSheets (Cell $ cell ): ?Table
161
+ {
162
+ $ spreadsheet = $ cell ->getWorksheet ()->getParent ();
163
+
164
+ foreach ($ spreadsheet ->getAllSheets () as $ sheet ) {
165
+ $ table = $ sheet ->getTableByName ($ this ->tableName );
166
+ if (null !== $ table ) {
167
+ return $ table ;
168
+ }
169
+ }
170
+
171
+ return null ;
172
+ }
173
+
156
174
private function getColumns (Cell $ cell , array $ tableRange ): array
157
175
{
158
176
$ worksheet = $ cell ->getWorksheet ();
You can’t perform that action at this time.
0 commit comments