Used addList(), but there is always an indent in the cell, which I do not want.
Hello,
When a content is added to a cell two indentations/margins are applied:
To remove the cell margins when using addTable you need to use the cellMargin option (or apply a custom table style to set margin values):
$valuesTable = array(
array(
array(
'cellMargin' => 0,
'value' => 'Content',
),
array(
'cellMargin' => 0,
'value' => 'Content',
),
),
array(
array(
'cellMargin' => 0,
'value' => 'Content',
),
array(
'cellMargin' => 0,
'value' => 'Content',
),
)
);
$docx->addTable($valuesTable);
If you also want to remove the indentations/margins from the content you are adding, then you need to set custom indentations to overwrite the default ones, for example when adding a list as a WordFragment you can use a custom list style (created dynamically or imported):
$listStyleOptions = array();
$listStyleOptions[0]['type'] = 'bullet';
$listStyleOptions[0]['left'] = '1';
$listStyleOptions[0]['hanging'] = '1';
$docx->createListStyle('my_custom_list_style', $listStyleOptions);
$list = new WordFragment($docx);
$itemList = array(
'Line 1',
'Line 2',
'Line 3',
);
$list->addList($itemList, 'my_custom_list_style');
$valuesTable = array(
array(
array(
'cellMargin' => 0,
'value' => 'Content',
),
array(
'cellMargin' => 0,
'value' => 'Content',
),
),
array(
array(
'cellMargin' => 0,
'value' => 'Content',
),
array(
'cellMargin' => 0,
'value' => $list,
),
)
);
$docx->addTable($valuesTable);
Regards.