Reputation: 20098
I'm using XLSX and alasql to export json object in to excel getting workbook is empty error, how to resolve
import * as alasql from 'alasql'
import * as XLSX from 'xlsx'
alasql.utils.isBrowserify = false
alasql.utils.global.XLSX = XLSX
const fileName = 'Ticket Details ' + props.ticketNumber
alasql('SELECT INTO XLSX("' + fileName + '.xlsx",?) FROM ?', [opts, finalData])
Upvotes: 0
Views: 356
Reputation: 20098
After debugging the code I got to know my finalData Array is empty, then I corrected the array value
Solution:
import * as alasql from 'alasql'
import * as XLSX from 'xlsx'
alasql.utils.isBrowserify = false
alasql.utils.global.XLSX = XLSX
const finalData = [
{name:"John", city: "Seattle"},
{name:"Mike", city: "Los Angeles"},
{name:"Zach", city: "New York"}
]
const fileName = 'Ticket Details ' + props.ticketNumber
alasql('SELECT INTO XLSX("' + fileName + '.xlsx",?) FROM ?', [opts, finalData])
Upvotes: 0