diff --git a/src/file/table/table-properties/table-width.ts b/src/file/table/table-properties/table-width.ts index 957fe49094..a463e958df 100644 --- a/src/file/table/table-properties/table-width.ts +++ b/src/file/table/table-properties/table-width.ts @@ -15,6 +15,7 @@ class TableWidthAttributes extends XmlAttributeComponent { export class PreferredTableWidth extends XmlComponent { constructor(type: WidthType, w: number) { super("w:tblW"); - this.root.push(new TableWidthAttributes({ type, w })); + const width: number | string = type === WidthType.PERCENTAGE ? `${w}%` : w; + this.root.push(new TableWidthAttributes({ type: type, w: width })); } } diff --git a/src/file/table/table.spec.ts b/src/file/table/table.spec.ts index ae470abc4c..f582e516ec 100644 --- a/src/file/table/table.spec.ts +++ b/src/file/table/table.spec.ts @@ -200,7 +200,7 @@ describe("Table", () => { .which.is.an("array") .with.has.length.at.least(1); expect(tree["w:tbl"][0]).to.deep.equal({ - "w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": 1000 } }] }], + "w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": "1000%" } }] }], }); });