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

Inserting a table with 8 columns does not work #264

Closed scottgubrud closed 6 years ago

scottgubrud commented 6 years ago

I'm trying to output some data to a table in word doc. However when I try to write a table with 8 or more columns the resulting file is unreadable.
My code:

 const fs = require("fs");
 const docx = officegen("docx");
 const tableOptions = {
    tableColWidth: 4261,
    borders: true,
    tableFontFamily: "Times New Roman"
};
const buffer = fs.createWriteStream("out.docx");
const table = [["0","1","2","3","4","5","6","7"]];
docx.createTable(table, tableOptions);
docx.generate(buffer, {
    'finalize': function (written) {
        console.log('Finished writing file.');
    }
});

The code runs without any errors but the resulting document looks like this.

officegenoutput
scottgubrud commented 6 years ago

JK Im an idiot. I just have to colWidth set so its to large to fit on the page.