Hi,
Need a bit help here, I am very much new to Retool and Js. I am trying to execute the Js code in the workflow but every time it gives me error with msg: ReferenceError: ExcelJS is not defined (line 2). Not sure how to import/define ExcelJS module. Any idea how to resolve this ?
Below is the code I am trying to run.
async function exportData() {
const workbook = new ExcelJS.Workbook();
const sheet = workbook.addWorksheet('My Sheet');
sheet.addTable({
name: 'MyTable',
ref: 'A1',
style: { theme: 'TableStyleDark3', showRowStripes: true },
columns: [{ name: 'Date' }, { name: 'Amount' }],
rows: [
[new Date('2019-07-20'), 70.10],
[new Date('2019-07-21'), 70.60],
[new Date('2019-07-22'), 70.10],
],
});
const buffer = await workbook.xlsx.writeBuffer()
utils.downloadFile({ base64Binary: buffer.toString('base64')}, "file-name", "xlsx")
}
return exportData()
Thanks in advance for any help !!