简体   繁体   中英

XLSX save file instead of downloading on frontend

I am a little new to javascript. I have got one javascript function which is generating xlsx file from HTML table. It's working fine but as soon as the file gets generated, it's downloading the file instead I am looking to save it on my server. The function is like below

function ExportToExcel(type, fn, dl) {
       var elt = document.getElementById('tour');
       var wb = XLSX.utils.table_to_book(elt, { sheet: "sheet1" });
       return dl ?
         XLSX.write(wb, { bookType: type, bookSST: true, type: 'base64' }):
         XLSX.writeFile(wb, fn || ('MySheetName.' + (type || 'xlsx')));
}

and I am calling it like below:

onclick="ExportToExcel('xlsx')"

How to store the file instead of downloading it?

Not understanding why you want to generate XLSX on the Client and save it to the server later on. I suggest you generate it on the server itself.

Take a look at answers to this question if you want to save/generate an XLSX file in Node.JS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM