Hello,
I 've added two tables with addTable() method.
How can I add the second table without having a carriage return between the two?
I'd like to have the second inline with the first.
Thanks,
Hello,
I 've added two tables with addTable() method.
How can I add the second table without having a carriage return between the two?
I'd like to have the second inline with the first.
Thanks,
Hello,
MS Word requires adding a paragraph between tables:
https://wordribbon.tips.net/T011729_Spacing_Before_and_After_Tables.html
If you open MS Word, a table is added and then you try to add a new table without adding at least a paragraph you can check MS Word doesn't allow adding the new table.
The best solution is generating a single table (instead of two) or adding a paragraph with the minimum space (https://stackoverflow.com/questions/59106925/html-to-doc-add-minimum-space-between-tables), for example, using phpdocx to set the minimum space between tables:
$docx = new CreateDocx();
$valuesTable = array(
array('A.1', 'A.2'),
array('B.1', 'B.2')
);
$paramsTable = array(
'border' => 'single',
);
$docx->addTable($valuesTable, $paramsTable);
// new paragraph with the minimum size
$docx->addText('', array('fontSize' => 1, 'spacing' => 0, 'spacingBottom' => 0, 'spacingTop' => 0, 'lineSpacing' => 0));
// remove borderTop for the cells of the first row of the second table to avoid adding two borders
$col_1_1 = array(
'value' => 'N.1',
'border' => 'single',
'borderTop' => 'nil',
);
$col_1_2 = array(
'value' => 'N.2',
'border' => 'single',
'borderTop' => 'nil',
);
$valuesTable = array(
array($col_1_1, $col_1_2),
);
$paramsTable = array(
'border' => 'single',
);
$docx->addTable($valuesTable, $paramsTable);
If you need to add a lot of tables, instead of setting the syles in each paragraph to separate paragrahs you can create a custom paragraph style using customParagraphStyle.
Regards.