Hello,
The easiest approach with phpdocx 16 to accomplish the requested task is to apply a transparent background to the cell contents. Please note that you need to wrap the text contents in tags (such as p or span ) to apply styles to the contents.
For example:
$html = '
<style>
td {
background-color: yellow;
}
td p, td span {
background-color: transparent;
}
</style>
<table border="1" style="border-collapse: collapse" width="500">
<tbody>
<tr>
<td width="400"><p>1_1</p></td>
<td width="400"><p>1_2</p></td>
</tr>
<tr>
<td><span>2_1</span></td>
<td><span>2_2</span></td>
</tr>
</tbody>
</table>';
$docx->embedHTML($html);
This same approach may work with some previous phpdocx versions.
Regards.