Monece Solis Monece Solis - 7 months ago 53
Javascript Question

how to use createAndFillWorkbook() in exceljs?

I followed the documentation

var workbook = createAndFillWorkbook();

and I get this
error Object # has no method 'createAndFillWorkbook'

even if I required exceljs already

var Excel = require("exceljs");

What I wanted to do was to create a report but I am somehow confused on the documentation because it does not say here how to use the createAndFillWorkbook() method it just says here to use it right away.

I referred here in the documentation:


createAndFillWorkbook(); does not mean a function.(maybe pseudo function)

You must create some workbook then fill content.

See below.

// create workbook by api.
var workbook = new Excel.Workbook();

// must create one more sheet.
var sheet = workbook.addWorksheet("My Sheet");

// you can create xlsx file now.
workbook.xlsx.writeFile("C:\\somepath\\some.xlsx").then(function() {
    console.log("xls file is written.");