提问人:KARTHIKEYAN.A 提问时间:7/4/2022 更新时间:7/4/2022 访问量:181
未捕获的错误:xlsx 和 alasql excel 文件导出中的工作簿为空
Uncaught Error: Workbook is empty in xlsx and alasql excel file export
问:
我正在使用 XLSX 和 alasql 将 json 对象导出到 excel 获取工作簿是空错误,如何解决
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])
答:
0赞
KARTHIKEYAN.A
7/4/2022
#1
调试代码后,我知道我的 finalData 数组是空的,然后我更正了数组值
溶液:
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])
评论