|
91 | 91 | $table->addCell(2000, $cellVCentered)->addText(htmlspecialchars('D', ENT_COMPAT, 'UTF-8'), null, $cellHCentered);
|
92 | 92 | $table->addCell(null, $cellRowContinue);
|
93 | 93 |
|
94 |
| -// 4. Nested table |
| 94 | +/** |
| 95 | + * 4. colspan (gridSpan) and rowspan (vMerge) |
| 96 | + * --------------------- |
| 97 | + * | | B | 1 | |
| 98 | + * | A | |----| |
| 99 | + * | | | 2 | |
| 100 | + * | |---|----|----| |
| 101 | + * | | C | D | 3 | |
| 102 | + * --------------------- |
| 103 | + * @see https://github.com/PHPOffice/PHPWord/issues/806 |
| 104 | + */ |
| 105 | +$section->addPageBreak(); |
| 106 | +$section->addText(htmlspecialchars('Table with colspan and rowspan', ENT_COMPAT, 'UTF-8'), $header); |
| 107 | + |
| 108 | +$styleTable = ['borderSize' => 6, 'borderColor' => '999999']; |
| 109 | +$phpWord->addTableStyle('Colspan Rowspan', $styleTable); |
| 110 | +$table = $section->addTable('Colspan Rowspan'); |
| 111 | + |
| 112 | +$row = $table->addRow(); |
| 113 | + |
| 114 | +$row->addCell(null, ['vMerge' => 'restart'])->addText('A'); |
| 115 | +$row->addCell(null, ['gridSpan' => 2, 'vMerge' => 'restart',])->addText('B'); |
| 116 | +$row->addCell()->addText('1'); |
| 117 | + |
| 118 | +$row = $table->addRow(); |
| 119 | +$row->addCell(null, ['vMerge' => 'continue']); |
| 120 | +$row->addCell(null, ['vMerge' => 'continue','gridSpan' => 2,]); |
| 121 | +$row->addCell()->addText('2'); |
| 122 | +$row = $table->addRow(); |
| 123 | +$row->addCell(null, ['vMerge' => 'continue']); |
| 124 | +$row->addCell()->addText('C'); |
| 125 | +$row->addCell()->addText('D'); |
| 126 | +$row->addCell()->addText('3'); |
| 127 | + |
| 128 | +// 5. Nested table |
95 | 129 |
|
96 | 130 | $section->addTextBreak(2);
|
97 | 131 | $section->addText(htmlspecialchars('Nested table in a centered and 50% width table.', ENT_COMPAT, 'UTF-8'), $header);
|
|
0 commit comments