NPM install - save XLSX file - saver
After installing the dependence:
ExportExcel () {
/* generate workbook object from the table/
Var wb=XLSX. Utils. Table_to_book (document. QuerySelector (" # excel "));
/get binary string as the output */
Var wbout=XLSX. Write (wb, {
BookType: "XLSX,"
BookSST: true,
Type: "array"
});
Try {
FileSaver. SaveAs (
New Blob ([wbout] and {type: "application/octet - stream"}),
"Sheetjs. XLSX"
);
} the catch (e) {
If (typeof console! .=="undefined") the console log (e, wbout);
}
Return wbout;
},
Export Excel Numbers become scientific notation is too long, how can I solve
CodePudding user response:
ExportExcel () {/* when converted to excel, use the original format, solving the problem of digital column automatically turn scientific notation */
Let xlsxParam={raw: true};
/* out - table associated exported dom node */
Let wb=XLSX. Utils. Table_to_book (document. QuerySelector (' # out - table), xlsxParam);
/* get binary string as the output */
Let wbout=XLSX. Write (wb, {bookType: 'XLSX, bookSST: true, type: "array"});
Try {
FileSaver. SaveAs (new Blob ([wbout] and {type: 'application/octet stream -'}), 'the MOS shop goods commodity import failure data. XLSX');
} the catch (e) {
If (typeof console! Undefined==' ') to the console. The log (e, wbout);
}
Return wbout;
}