dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
https://docx.js.org/
MIT License
4.24k stars 479 forks source link

exmaple/31-tables creates table with no cell width #2723

Open shyamayadav154 opened 3 weeks ago

shyamayadav154 commented 3 weeks ago
image
anti-the-social commented 3 weeks ago

Open it in Word :)

shyamayadav154 commented 3 weeks ago

The file works in Microsoft Word, but not in Google Docs or Apple Pages. Does this library not support these two platforms? However, if I modify the file in MS Word and then open it in Google Docs or Apple Pages, it displays correctly with correct cell width.

anti-the-social commented 3 weeks ago

They are not as smart as Word. Word does re-calculate width values for you in the background. So if you re-save with Word then width will be fixed and tables openable in other editors.

There is tonns of issues opened concerning that in the past. e.g. https://github.com/dolanmiu/docx/issues/1947 https://github.com/dolanmiu/docx/issues/2712

To my knowledge such recalculation isn't planned to be as a part of docxjs library due to technical reasons.

To make tables work in every editor you have to set absolute widths.