First, if you didn't have it yet, get access to the officegen module:
const officegen = require('officegen')
Now you have few ways to use it to create a xlsx based document. The simple way is to use this code:
let xlsx = officegen('xlsx')
But if you want to pass some settings then you should use the following format:
let xlsx = officegen({
type: 'xlsx', // We want to create a Microsoft Excel document.
... // Extra options goes here.
})
You can always change some of these settings after creating the xlsx object using there methods:
xlsx.setDocTitle('...')
xlsx.setDocSubject('...')
xlsx.setDocKeywords('...')
xlsx.setDescription( '...')
xlsx.setDocCategory('...')
xlsx.setDocStatus('...')
Fill cells:
// Using setCell:
sheet.setCell ( 'E7', 340 );
sheet.setCell ( 'G102', 'Hello World!' );
// Direct way:
sheet.data[0] = [];
sheet.data[0][0] = 1;
sheet.data[0][1] = 2;
sheet.data[1] = [];
sheet.data[1][3] = 'abc';