Docx: Column width property doesnt work when there's text in the cells

Created on 10 Jul 2019  路  3Comments  路  Source: dolanmiu/docx

I am trying to add column width of 12.5% for all and i have 8 columns
If there's no text in any cell then they follow the spacing specified by columnWidths, But when there's text, they are not following the given width size
Here is my code -

const doc = new Document();
const abc = new Table({
    rows: 8,
    columns: 8,
    width: 100,
    columnWidths: new Array(8).fill(12.5),
    widthUnitType: WidthType.PERCENTAGE,
});

abc.getCell(0, 0).addParagraph(new Paragraph("Hellohello hellohellohello"));

doc.addTable(abc);

and this is the result
Screenshot 2019-07-10 at 4 32 13 PM

bug

Most helpful comment

add the function abc.setFixedWidthLayout()

All 3 comments

add the function abc.setFixedWidthLayout()

add the function abc.setFixedWidthLayout()

Thanks! this worked!!

In case it helps, you can also use the layout property

new Table({
  width: {...},
  layout: "fixed",
  rows: [...],
  ...
})

Btw could @zahrafali please close this issue?

Was this page helpful?
0 / 5 - 0 ratings