@@ -294,36 +294,37 @@ public function setUpWidths(string $availableSpace)
294
294
{
295
295
foreach ($ this ->getChildren () as $ rowGroup ) {
296
296
foreach ($ rowGroup ->getChildren () as $ row ) {
297
- $ columns = $ row ->getChildren ();
298
- foreach ($ columns as $ columnIndex => $ column ) {
299
- $ cell = $ column ->getFirstChild ();
300
- $ cellStyle = $ cell ->getStyle ();
301
- $ columnInnerWidth = $ cell ->getDimensions ()->getMaxWidth ();
302
- $ styleWidth = $ column ->getStyle ()->getRules ('width ' );
303
- $ this ->contentWidths [$ columnIndex ] = Math::max ($ this ->contentWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
304
- $ minColumnWidth = $ cell ->getDimensions ()->getMinWidth ();
305
- if ($ column ->getColSpan () > 1 ) {
306
- $ minColumnWidth = Math::div ($ minColumnWidth , (string ) $ column ->getColSpan ());
307
- }
308
- $ this ->minWidths [$ columnIndex ] = Math::max ($ this ->minWidths [$ columnIndex ] ?? '0 ' , $ minColumnWidth );
309
- if ('auto ' !== $ styleWidth && false === strpos ($ styleWidth , '% ' )) {
297
+ if ($ columns = $ row ->getChildren ()) {
298
+ foreach ($ columns as $ columnIndex => $ column ) {
299
+ $ cell = $ column ->getFirstChild ();
300
+ $ cellStyle = $ cell ->getStyle ();
301
+ $ columnInnerWidth = $ cell ->getDimensions ()->getMaxWidth ();
302
+ $ styleWidth = $ column ->getStyle ()->getRules ('width ' );
303
+ $ this ->contentWidths [$ columnIndex ] = Math::max ($ this ->contentWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
304
+ $ minColumnWidth = $ cell ->getDimensions ()->getMinWidth ();
310
305
if ($ column ->getColSpan () > 1 ) {
311
- $ styleWidth = Math::div ($ styleWidth , (string ) $ column ->getColSpan ());
306
+ $ minColumnWidth = Math::div ($ minColumnWidth , (string ) $ column ->getColSpan ());
312
307
}
313
- $ preferred = Math::max ($ styleWidth , $ minColumnWidth );
314
- $ this ->minWidths [$ columnIndex ] = $ preferred ;
315
- } elseif (strpos ($ styleWidth , '% ' ) > 0 ) {
316
- $ preferred = Math::max ($ this ->preferredWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
317
- $ this ->percentages [$ columnIndex ] = Math::max ($ this ->percentages [$ columnIndex ] ?? '0 ' , trim ($ styleWidth , '% ' ));
318
- } else {
319
- $ preferred = Math::max ($ this ->preferredWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
308
+ $ this ->minWidths [$ columnIndex ] = Math::max ($ this ->minWidths [$ columnIndex ] ?? '0 ' , $ minColumnWidth );
309
+ if ('auto ' !== $ styleWidth && false === strpos ($ styleWidth , '% ' )) {
310
+ if ($ column ->getColSpan () > 1 ) {
311
+ $ styleWidth = Math::div ($ styleWidth , (string ) $ column ->getColSpan ());
312
+ }
313
+ $ preferred = Math::max ($ styleWidth , $ minColumnWidth );
314
+ $ this ->minWidths [$ columnIndex ] = $ preferred ;
315
+ } elseif (strpos ($ styleWidth , '% ' ) > 0 ) {
316
+ $ preferred = Math::max ($ this ->preferredWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
317
+ $ this ->percentages [$ columnIndex ] = Math::max ($ this ->percentages [$ columnIndex ] ?? '0 ' , trim ($ styleWidth , '% ' ));
318
+ } else {
319
+ $ preferred = Math::max ($ this ->preferredWidths [$ columnIndex ] ?? '0 ' , $ columnInnerWidth );
320
+ }
321
+ $ this ->preferredWidths [$ columnIndex ] = $ preferred ;
320
322
}
321
- $ this ->preferredWidths [$ columnIndex ] = $ preferred ;
323
+ $ this ->borderWidth = Math::add ($ this ->borderWidth , $ cellStyle ->getHorizontalBordersWidth ());
324
+ $ this ->minWidth = Math::add ($ this ->minWidth , $ this ->minWidths [$ columnIndex ]);
325
+ $ this ->contentWidth = Math::add ($ this ->contentWidth , $ this ->contentWidths [$ columnIndex ]);
326
+ $ this ->preferredWidth = Math::add ($ this ->preferredWidth , $ this ->preferredWidths [$ columnIndex ]);
322
327
}
323
- $ this ->borderWidth = Math::add ($ this ->borderWidth , $ cellStyle ->getHorizontalBordersWidth ());
324
- $ this ->minWidth = Math::add ($ this ->minWidth , $ this ->minWidths [$ columnIndex ]);
325
- $ this ->contentWidth = Math::add ($ this ->contentWidth , $ this ->contentWidths [$ columnIndex ]);
326
- $ this ->preferredWidth = Math::add ($ this ->preferredWidth , $ this ->preferredWidths [$ columnIndex ]);
327
328
}
328
329
}
329
330
if ('collapse ' !== $ this ->getParent ()->getStyle ()->getRules ('border-collapse ' )) {
@@ -358,9 +359,9 @@ protected function setUpSizingTypes()
358
359
foreach ($ this ->getChildren () as $ rowGroup ) {
359
360
foreach ($ rowGroup ->getChildren () as $ row ) {
360
361
foreach ($ row ->getChildren () as $ columnIndex => $ column ) {
361
- if ('percent ' === $ columnSizingTypes [$ columnIndex ]) {
362
+ if (isset ( $ columnSizingTypes [ $ columnIndex ]) && 'percent ' === $ columnSizingTypes [$ columnIndex ]) {
362
363
$ this ->percentColumns [$ columnIndex ][] = $ column ;
363
- } elseif ('pixel ' === $ columnSizingTypes [$ columnIndex ]) {
364
+ } elseif (isset ( $ columnSizingTypes [ $ columnIndex ]) && 'pixel ' === $ columnSizingTypes [$ columnIndex ]) {
364
365
$ this ->pixelColumns [$ columnIndex ][] = $ column ;
365
366
} else {
366
367
$ this ->autoColumns [$ columnIndex ][] = $ column ;
@@ -1287,7 +1288,7 @@ public function measureHeight(bool $afterPageDividing = false)
1287
1288
}
1288
1289
// column that is spanned with more than 1 row must have height that is equal to all spanned rows height
1289
1290
foreach ($ rows as $ rowIndex => $ row ) {
1290
- $ currentRowMax = $ maxRowHeights [$ rowGroupIndex ][$ rowIndex ];
1291
+ $ currentRowMax = $ maxRowHeights [$ rowGroupIndex ][$ rowIndex ] ?? ' 0 ' ;
1291
1292
foreach ($ row ->getChildren () as $ column ) {
1292
1293
$ rowSpan = $ column ->getRowSpan ();
1293
1294
if ($ rowSpan > 1 ) {
0 commit comments