Hello, I would like to delete a complete row from a spreadsheet that contains a variable.
Example:
variable : $test$ (in second columns to third row), i would like delete third row.
Can you help me?
Thank you
I have prenium licences
Hello, I would like to delete a complete row from a spreadsheet that contains a variable.
Example:
variable : $test$ (in second columns to third row), i would like delete third row.
Can you help me?
Thank you
I have prenium licences
Hello,
You can use the removeWordContent method available in DOCXPath to remove contents in a DOCX document. We recommend you to check the samples included in the package (examples/DocxPath/removeWordContent folder), that illustrates how to use this method; sample_9.php illustrates how to remove a row in a table.
Regards.
Thank you for your reply.
In the example (sample_9), the line is already indicated,.
$referenceNode = array(
'customQuery' => '//w:tbl/w:tr[2]',
);$docx->removeWordContent($referenceNode);
How to retrieve the row number of the correct table when looking for the variable. I can't find any documentation on this subject
Thank you
Hello,
The customQuery option allows using a custom XPath query (https://www.w3schools.com/xml/xpath_intro.asp). If you know a text content available in a table row you can use the contains function available in XPath, instead of setting the position. For example, using a DOCX document included in the package, you can remove the row that includes 24 running:
$referenceNode = array(
'customQuery' => '//w:tbl/w:tr[contains(.,"24")]',
);
$docx->removeWordContent($referenceNode);
You can also get DOCXPath query information using the following method: getDocxPathQueryInfo. DOCXPath and XPath includes many options to choose the contents to be changed, updated, removed, cloned, inserted...
Please note that XPath has some protected characters that you may need to escape if you want to query by a text with protected characters.
If you open a support ticket (https://www.phpdocx.com/support) attaching the DOCX you want to modify, the dev team will generate a custom code using your template.
Regards.