Forum


Replies: 2   Views: 1836
How to read page and table-cell properties
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 admin  · 10-09-2020 - 07:12

Hello,

To query cell and rows in tables, you need to set the parent option, for example, using the document SimpleExample.docx in the package:

$docx = new CreateDocxFromTemplate('SimpleExample.docx');
$referenceNode = array(
    'type' => 'table-cell',
    'parent' => 'w:tbl/w:tr/',
    'contains' => 'First row',
);

$contents = $docx->getWordStyles($referenceNode);

You can read a sample of getting cell and row information in examples/DocxPath/getWordStyles/sample_7.php

Although First row (as A1 in your DOCX), is included in a paragraph, this paragrah is also include in the cell (w:tc) so the query returns the correct information. Also please note that some styles can be applied to table (w:tbl) or even a custom table style (getWordStyles is compatible with both), so you'd need to query them too depending on how the DOCX was created.

About gettion layout values, you can use Indexer: https://www.phpdocx.com/api-documentation/docxutilities/indexer-parse-word-documents-with-PHP, layout is set in sections.

Regards.