Forum


Replies: 2   Views: 1829
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 dan_brokerbusiness  · 10-09-2020 - 01:40

Hi

I have a simple word document with a table with two cells that contain A1 and A2 respectively (see https://ibb.co/pRS2xN1).

I need to

  • Find the table-cell styling (background, border/borderWidth/borderColor) of the cells containing A1 and A2
  • Find out the margins of the document (basically a getPageLayout() equivalent to modifyPageLayout())

Is this possible with phpdocx? Are there any examples on how to go about this?

I have been trying to use getWordStyles() but without much luck. Even using something as simple as:

$docx = new CreateDocxFromTemplate(resource_path('word/query_test.docx'));
$referenceNode = array(
   'type' => 'table-cell',
);
print_r($docx->getWordStyles($referenceNode));

I would at least expect some output but I don't get anything. Also tried

$referenceNode = array(
   'type' => 'table-cell',
   'contains' => 'A1',
);

Which would be my ideal solution of course but probably won't work as A1 itself is a paragraph and I would have to construct a query to search for table cell containing a paragraph that contains A1 instead. But as I don't get anything with just searching for type 'table-cell' I am not sure this is even possible.

Any help appreciated.

Regards