Create Word documents with properly formatted tables using docx npm library. Tables work consistently across Word and Google Docs. Use when creating DOCX files with tables, especially itineraries, schedules, or data tables.
Create Word documents with tables that work everywhere - Word, Google Docs, etc.
Set widths in TWO places - on table AND on each cell:
// Table level
new Table({
width: { size: 9360, type: WidthType.DXA },
columnWidths: [1872, 7488],
rows: [...]
})
// Cell level - EVERY cell needs width!
new TableCell({
width: { size: 1872, type: WidthType.DXA },
children: [...]
})
Percentages break in Google Docs. Use DXA:
// ❌ WRONG