Forum


Replies: 2   Views: 1750
Get the height/width of a cell based on a search term
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 bkidd  · 02-05-2020 - 22:40

I'd like to get the height and width of a cell based on the cell contents.  Is there anyway to get a reference to the cell and then get the dimensions of it?

My app allows someone to upload a template and then based on template contents, get the cell height and width so I can generate a barcode image that is the same size as the cell.  Using other libraries, I've been able to get the cell height and width but not sure if there is a way to do it with phpdocx.

Thanks

Posted by admin  · 04-05-2020 - 10:35

Hello,

If they use fixed values, you can use getWordStyles (https://www.phpdocx.com/api-documentation/docx-path/get-styles-word-contents-in-docx) to query styles:

· w:tcW tag for width in cells

· w:trHeight tag for height in rows

But the size of a cell may vary when margins, borders, and other styles are applied. But MS Word may use automatic styles, so the final size is unknown until the DOCX is opened.

Regards.

Posted by bkidd  · 04-05-2020 - 12:00

Okay, thanks.