javascript - Undefined is not a function when creating a Workbook -
when attempting create excel spreadsheet in node.js, why following code not work?
var excel = require("xlsx"); workbook = new excel.workbook(); excel.writefile(workbook, 'out.xlsx'); i error:
workbook = new excel.workbook(); ^ typeerror: undefined not function how should doing differently? i'm stumped.
it doesn't appear workbook exported method of "xlsx". in fact, whole library doesn't appear support creating file scratch. did find posting quite helpful you: how create excel file nodejs?
taking that, i'd recommend first trying second answer, installing node package "msexcel-builder" looks it's accepted answer less file write streaming work on part.
alternatively, using posting's accepted answer, modify bit to:
var fs = require('fs'); var writestream = fs.createwritestream("file.xls"); writestream.close(); var excel = require("xlsx"); var workbook = excel.readfile('file.xls'); excel.writefile(workbook, 'out.xlsx');
Comments
Post a Comment