npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

How do I convert WorkBook to base64 and download instead of writing it into a file.

const XLSX = require(‘xlsx’)

const balance = [{i have data here}]
const account = [{}]

var accountWS = XLSX.utils.json_to_sheet(account)
var balanceWS = XLSX.utils.json_to_sheet(balance)
// A workbook is the name given to an Excel file
var wb = XLSX.utils.book_new() // make Workbook of Excel
// add Worksheet to Workbook
// Workbook contains one or more worksheets
XLSX.utils.book_append_sheet(wb, accountWS, ‘ACCOUNT’) // sheetAName is name of Worksheet
XLSX.utils.book_append_sheet(wb, balanceWS, ‘BALANCE’)

Instead of writing this i want to get a base64 link using which i can download the file not save it.
//XLSX.writeFile(wb, ‘book.xlsx’)

(You might get an answer here, but because this forum is focused on npm, you might want to ask your question somewhere that targets experts with your package. I have moved your topic to #community:javascript)