Search code examples
javascriptnode.jsopenxml

Writing string blob to file (XLSX templating with Node)


I'm using the xlsx-template library to generate Excel documents. I'm recreating the example from the github readme and I'm stuck on the first step - the standard templating function returns a 'string blob' representing the excel file.

How do I write a string blob to the file system in node?


Solution

  • Figured it out:

    fs.writeFileSync(
        path.join(__dirname, 
        'templates', 
        'output.xlsx'), 
        data, 
        'binary', 
        function (err) { [...]
    

    The third parameter, 'binary', was key.