Forum


Replies: 2   Views: 148
Removewordcontent with type table-row
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by avandoorine  · 20-08-2024 - 12:10

Hello.

I may have found a small issue ith the removeWordContent.

My need is to remove a table row base on some condition, so as a trial I did this code : 
 

$referenceNode = array(
    'type' => 'table-row',
    'contains' => 'Bravo',
);

$docx->removeWordContent($referenceNode);

The goal is to remove table row if one of the cell contains Bravo. In my test file I have three rows with Alpha, Bravo and Charlie.

The issue is that it does not work, I can delete the complete table with the type set to table but the type table-row does not remove anythin.

I have found a workaround using the customQuery with this code 

$referenceNode = array(
    'customQuery' => '//w:tbl/w:tr[contains(.,"Bravo")]',
);

$docx->removeWordContent($referenceNode);

But it seems to me that the first code should be working as well.