table width property not working for google and microsoft doc
See original GitHub issueHi, all I have trying around to create a table with width 100% having two columns with width 50% each, but the table is not taking full doc width in Microsoft doc and google doc. Here is the code that i am using
let rowmatch = Object.keys(state.match_keys).length;
const tablematch = doc.createTable(rowmatch, 2).setWidth('pct', '100%');
Object.keys(state.match_keys).map((key, i) => {
const parakey = new docx.Paragraph().spacing({
before: 20,
after: 20
});
parakey.addRun(
new docx.TextRun(`${key}`)
.font("Verdana")
.size(20)
.color("#2b2b2b")
);
parakey.addRun(new docx.TextRun("").break());
const paraval = new docx.Paragraph().spacing({
before: 20,
after: 20
});
paraval.addRun(
new docx.TextRun(`${state.match_keys[key]}`)
.font("Verdana")
.size(20)
.color("#2b2b2b")
);
paraval.addRun(new docx.TextRun("").break());
tablematch.getCell(i, 0).addContent(parakey).CellProperties.setWidth('50%', 'pct');
tablematch.getCell(i, 1).addContent(paraval).CellProperties.setWidth('50%', 'pct');
});
I am using docx version 4.7.1 I have attached the screenshot for reference.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Column width won't adjust - Google Groups
1. Disable auto resizing (Options... on the Table tab). · 2. Disable any exact width for the entire table. · 3. Clear any...
Read more >fixing table width - Microsoft Community
Here's how you should follow: Select the table, then right click on it. ... Go back to Table Properties > Under Column Tab,...
Read more >How to fix tables that run off the page in Google Docs
The solution. The solution is to go to Table>Table Properties and then uncheck the column width button. This allows the table to resize....
Read more >5 Common table problems & its best solution - YouTube
Following are 5 most common problems encountered while working with tables in Ms Word. This video shows how to solve these problems in...
Read more >Google Docs: Fixing Tables You Copied and Pasted
To fix this, right-click on the column and choose “Table properties.” right click on the column and choose table properties. Adjust Column Width....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dolanmiu it looks like it’s a unit problem, Google Docs does not like percents. MS Word generates xml like this (which is GDocs compatible) :
And docx generates this :
It looks like the global width in % is ignored, and the gridCol value is interpreted as DXA. And the MS way is to set explicitly each column in DXA. Workaround with current version:
I it work on Google Docs. width doesn’t have to be set.