Skip to content

Commit 1dc34b7

Browse files
committed
support array type of before/after-colspan
1 parent 7bbc9a9 commit 1dc34b7

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/PhpWord/Shared/Html.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,17 @@ protected static function parseCell($node, $element, &$styles)
480480
if (!empty($beforespan)) {
481481
$cellRowContinue = array('vMerge' => 'continue');
482482
$beforecolspan = $node->getAttribute('beforecolspan');
483-
if (!empty($beforecolspan)) {
484-
$cellRowContinue['gridSpan'] = $beforecolspan;
485-
}
483+
486484
for ($s = 1; $s <= $beforespan; $s++){
485+
if (!empty($beforecolspan)) {
486+
if (is_numeric($beforecolspan)) {
487+
$beforecolspan = (int) $beforecolspan;
488+
} else {
489+
$beforecolspans = json_decode($beforecolspan, true);
490+
$beforecolspan = $beforecolspans[$s - 1];
491+
}
492+
$cellRowContinue['gridSpan'] = $beforecolspan;
493+
}
487494
$element->addCell(null, $cellRowContinue);
488495
}
489496
}
@@ -497,10 +504,17 @@ protected static function parseCell($node, $element, &$styles)
497504
if (!empty($afterspan)) {
498505
$cellRowContinue = array('vMerge' => 'continue');
499506
$aftercolspan = $node->getAttribute('aftercolspan');
500-
if( ! empty($aftercolspan) ) {
501-
$cellRowContinue['gridSpan'] = $aftercolspan;
502-
}
507+
503508
for($s = 1; $s <= $afterspan; $s++) {
509+
if (!empty($aftercolspan)) {
510+
if (is_numeric($aftercolspan)) {
511+
$aftercolspan = (int) $aftercolspan;
512+
} else {
513+
$aftercolspans = json_decode($aftercolspan, true);
514+
$aftercolspan = $aftercolspans[$s - 1];
515+
}
516+
$cellRowContinue['gridSpan'] = $aftercolspan;
517+
}
504518
$element->addCell(null,$cellRowContinue);
505519
}
506520
}

0 commit comments

Comments
 (0)