Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

javascript - Tabulator: Download Error - No such download type found

Would like to ask for some help I am currently using Tabulator (4.9) along with Vue. I am having trouble downloading/exporting my data to Excel. I have already included SheetJS on my project as stated from Tabulator's page.

The following gives me an error that the XLSX is not defined:

import 'xlsx/dist/xlsx.full.min.js'
this.tabulator.download('xlsx', 'data.xlsx')

But once I include the XLSX, then it tells me "Download Error - No such download type found":

import XLSX from 'xlsx/dist/xlsx.full.min.js'
this.tabulator.download(XLSX, 'data.xlsx')

Would really like to know if I am missing something.

Thanks.

question from:https://stackoverflow.com/questions/65883023/tabulator-download-error-no-such-download-type-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your first approach is correct, you should be calling the download function and passing in the xlsx string

this.tabulator.download('xlsx', 'data.xlsx');

The issue is that Tabulator is expecting to find the XLSX object on the window object (or global object if this is a node project) as that is where the library is put when pulled in from the CDN.

So in you case your import should be:

import XLSX from 'xlsx/dist/xlsx.full.min.js';
window.XLSX = XLSX;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...