-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting Specific Table Column Width #2571
Comments
You need to use layout style for table. layout is LAYOUT_FIXED
|
I still happened to have this setup in a folder, so tested this adjustment. As I thought, it still does not work in a similar manner to v0.18. The expectation here is that I can configure a single column's width, but allow the other columns to autofit as necessary. Once an entire table has the setting applied for LAYOUT_FIXED, it seems like all columns expect a custom width to be applied, or there will be indeterminate sizes applied. Even with the TIME column width explicitly set to a preferred width of 1.39", it can be clearly seen below that the width is indeed much larger than 1.39" after applying the LAYOUT_FIXED attribute to the table, as suggested above. I will need to update to the most recent version and see if this issue still applies under either layout setting for a table. NOTE: Images above taken from Microsoft Word 2016 |
Describe the Bug
The last version I had used (v0.18) prior to the current release, seemed to handle the creation of columns (for/in Microsoft Word) that, based on the twip, seemed to correlate to the appropriate inches (via internal Microsoft Word ruler) when rendered. I only needed to assign a width to a single cell within the row for the column (as shown below, this is the TIME column), and the other columns would auto-fit the content.
For version 1.2.0, this functionality has seemingly regressed for rendering in Microsoft Word (2016). LibreOffice appears to render better, but still incorrectly. I believe this is because PhpWord is now explicitly assigning column sizes in the
document.xml
file.Microsoft Word 2016 on PhpWord v0.18
Libre Office v24.2.0.3 on PhpWord v0.18
Microsoft Word 2016 on PhpWord v1.2.0
Libre Office v24.2.0.3 on PhpWord 1.2.0
In trying to track down the rendering differences between versions, I examined the uncompressed XML files to try to identify differences. The most glaring was in
word/document.xml
in the w:tblGrid definition. In version 0.18 the widths were only defined for the columns explicitly provided via PhpWord code/style, the other columns had no width attribute. This, however, had a detrimental impact on LibreOffice Writer. The updates may have caused a different result in rendering, and an unexpected one, but at least the rendering is the same in both editors. That said, attempting to modify the column width attributes and recompressing to a DOCX file did not provide any level of correction, so there must be a few other places where widths are defined.For reference, in v0.18, the column's Preferred Width in Microsoft Word was defined as 1.39". For v1.2.0, it is still reporting a Preferred Width of 1.39"...but is very obviously being prevented from rendering that way, from something else.
Steps to Reproduce
Please provide a code sample that reproduces the issue.
Expected Behavior
The expectation was that the 2000 twip units on the TIME column would've been set to the converted 1.39" column width, and the other columns would've auto-fit.
Current Behavior
The preferred width is set, but it seems that the other columns are overriding widths in some sort of calculated width...
Context
Please fill in your environment information:
The text was updated successfully, but these errors were encountered: