PHPWord
PHPWord copied to clipboard
Multicolumn layout is not working.
Describe the bug and add attachments
Adding a section with multiple columns has no effect on the resulting .docx.
E.g.
$phpWord->addSection( [
'colsNum' => $columns,
'colsSpace' => 1440,
'breakType' => 'continuous',
]);
I tried removing "Compatibility Mode" via $phpWord->getCompatibility()->setOoxmlVersion(15); to no effect.
And running the Sample_05_Multicolumn.php example also doesn't work. Neither the docx, HTML or ODT files have multiple columns
Actual result from phpWord
Expected result
Expected behavior
See the screenshot. I expect the document to have more than one column.
Steps to reproduce
Exactly as per https://github.com/PHPOffice/PHPWord/blob/master/samples/Sample_05_Multicolumn.php
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Remove 'compatibility mode'
$phpWord->getCompatibility()->setOoxmlVersion(15);
$filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' .
'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' .
'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' .
'Suspendisse congue congue leo sed pellentesque.';
// Normal
$section = $phpWord->addSection();
$section->addText('Normal paragraph. ' . $filler);
// Two columns
$section = $phpWord->addSection(array(
'colsNum' => 2,
'colsSpace' => 1440,
'breakType' => 'continuous'));
$section->addText('Two columns, one inch (1440 twips) spacing. ' . $filler);
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again. ' . $filler);
// Three columns
$section = $phpWord->addSection(array(
'colsNum' => 3,
'colsSpace' => 720,
'breakType' => 'continuous'));
$section->addText('Three columns, half inch (720 twips) spacing. ' . $filler);
// Normal
$section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again.');
PHPWord version(s) where the bug happened
master
PHP version(s) where the bug happened
8.1
Priority
- [ ] I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
- [ ] I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
Can anyone please assist with this?
Am I doing something wrong or does this just not work?
For now I'm faking "columns" via a table.
So first add a table and hide its borders, than for each "column", add a cell.
Then append whatever you want to that cell.
E.g.
$invisibleTableStyle = [
// how to get 100% widht? 50*50 is apparently 50% wide
// 'width' => 50 * 100, 'unit' => 'pct',
'borderSize' => 5, 'borderColor' => '00FFFF',
'cellSpacing' => 5, 'cellMargin' => 80,
'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::START,
];
$invisibleTableRowStyle = [];
$phpWord->addTableStyle('InvisibleTable', $invisibleTableStyle, $invisibleTableRowStyle);
$table = $phpWord->addTable('InvisibleTable');
$table->addRow();
foreach ($YOUR_COLUMS as $i => $subSection) {
$cell = $table->addCell(null, null);
$cell->addText( "COLUMN {$i}");
// $cell->addChart();
// etc.
}
@iedev1 Could you send me two files for analysis, please ?
(With Bad multicolumn and good multicolumn)