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

Bug: Table gridspan, vMerge together #806

Closed
githubjeka opened this issue May 30, 2016 · 1 comment
Closed

Bug: Table gridspan, vMerge together #806

githubjeka opened this issue May 30, 2016 · 1 comment
Milestone

Comments

@githubjeka
Copy link
Contributor

githubjeka commented May 30, 2016

I'm trying to do here so:
image

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection(
    [
        'orientation' => 'landscape',
        'marginTop' => 600,
        'marginLeft' => 600,
        'marginRight' => 600,
        'marginBottom' => 600,
    ]
);

$tableStyle = [
    'width' => 100,
    'borderSize' => 6,
    'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER,
];

$phpWord->addTableStyle('myTable', $tableStyle);
$table = $section->addTable('myTable');

$row = $table->addRow();

$row->addCell(4200, ['valign' => 'center', 'vMerge' => 'restart'])
    ->addText('A', null, ['align' => 'center']);

$row->addCell(null, ['textDirection' => Cell::TEXT_DIR_BTLR, 'gridSpan' => 2, 'vMerge' => 'restart',])
    ->addText('B', null, ['align' => 'center']);

$row->addCell(null, ['textDirection' => Cell::TEXT_DIR_BTLR, 'gridSpan' => 4])
    ->addText('1', null, ['align' => 'center']);

$row = $table->addRow();
$row->addCell(null, ['vMerge' => 'continue']);
$row->addCell(null, ['vMerge' => 'continue']);
$row->addCell(null, ['vMerge' => 'continue']);
$row->addCell(null, ['gridSpan' => 2])->addText('2');
$row->addCell(null, ['gridSpan' => 2]);
$row = $table->addRow();
$row->addCell(null, ['vMerge' => 'continue']);
$row->addCell()->addText('C');
$row->addCell()->addText('D');
$row->addCell()->addText('3');
$row->addCell();
$row->addCell();
$row->addCell();

Result
image

To fix: Missing gridspan in the second block:

<w:tc>
     <w:tcPr>
         <w:tcW w:w="0" w:type="dxa"/>
          <!--here need gridSpan-->
         <w:vMerge/>
         </w:tcPr>
         <w:p w:rsidR="00907392" w:rsidRDefault="00907392"/>
</w:tc>
@githubjeka
Copy link
Contributor Author

Fixed:

$row->addCell(null, ['vMerge' => 'continue', 'gridSpan' => 2]);

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

No branches or pull requests

2 participants