Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicolumn layout is not working. #2627

Open
2 tasks
iedev1 opened this issue Jun 21, 2024 · 2 comments
Open
2 tasks

Multicolumn layout is not working. #2627

iedev1 opened this issue Jun 21, 2024 · 2 comments

Comments

@iedev1
Copy link

iedev1 commented Jun 21, 2024

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

phpWord - No Columns

Expected result

Word - Expected

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)
@iedev1
Copy link
Author

iedev1 commented Jun 25, 2024

Can anyone please assist with this?

Am I doing something wrong or does this just not work?

@iedev1
Copy link
Author

iedev1 commented Jun 25, 2024

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.
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant