Home > front end >  File - saver generate excel table directly to the background
File - saver generate excel table directly to the background

Time:01-07

Use the
NPM install file - saver - save
Bower install file - saver
On the browser to the excel table generated from the table, but can not download, formation, directly to the background, how come???????????
 
Export2Excel () {
Let tables=document. GetElementById (" out - table ");
Let table_book=this. $XLSX. Utils. Table_to_book (tables).
Var table_write=this. $XLSX. Write (table_book, {
BookType: "XLSX,"
BookSST: true,
Type: "array"
});
Try {
Let the userAgent=the navigator. UserAgent;
//compatible with ie browser
If (userAgent. IndexOf (" Trident ")!==1 & amp; & UserAgent. IndexOf (' Windows')!==1) {
Let the blob=new blob ([table_write], {type: 'application/octet stream -'});
The console. The log (blob);
This $FileSaver. SaveAs (blob, "sheetjs. XLSX");
} else {//compatible with Google firefox
Let the file=new file ([table_write], "sheetjs. XLSX," {type: "application/octet - stream"});
console.log(file);
This. $FileSaver. SaveAs (file);
}
} the catch (e) {
If (typeof console! .=="undefined") the console log (e, table_write);
}
Return table_write;
},
  • Related