Ziv-Barber / officegen

Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.
MIT License
2.65k stars 471 forks source link

Unable to set column widths #258

Closed dwatling-follett closed 6 years ago

dwatling-follett commented 6 years ago

We're trying to generate a docx file that contains a table with multiple columns. Each column should be able to have its own width, however it appears that all columns inherit the width of the first column. Example code is below:

var docx = officegen ( {
    type: 'docx',
    orientation: 'portrait'
} );

var table = [
    [
        {val: "Color", opts: { cellColWidth: 42 }},
        {val: "Create Date", opts: { cellColWidth: 1500 }},
        {val: "Text", opts: { cellColWidth: 1500 }},
        {val: "Note", opts: { cellColWidth: 1500 }}
    ]
];

var tableStyle = {
    tableSize: 24,
    tableColor: "ada",
    tableAlign: "left",
    tableFontFamily: "Arial",
    borders: true
};

docx.createTable (table, tableStyle);

Based on the documentation we expected the cellColWidth to drive the width of each column.

dwatling-follett commented 6 years ago

Scratch that. Turns out this is a bug in Google Docs.