Reference: https://www.jianshu.com/p/1971fc5b97ca
https://blog.csdn.net/qq_40614207/article/details/94003793
Code posted
// define an export Excel spreadsheet event exportExcel () { Solution generating duplicate data // - l fixed property since the use of var fix = document.querySelector('.el-table__fixed') There wB // determine whether there is fixed a table node to be exported, if there are, conversion excel to the dom removed, and then append back if (fix) { / * Generate Workbook object from the table * / wb = XLSX.utils.table_to_book(document.querySelector('#out-table').removeChild(fix)) document.querySelector('#out-table').appendChild(fix) } else { wb = XLSX.utils.table_to_book(document.querySelector('#out-table')) } / * Get a binary string as output * / var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' }) try { FileSaver.saveAs( // Blob object represents an immutable data object from the original class file. JavaScript is not necessarily the data in its native format // Blob represented. // File interface is based on Blob, blob inherited and extended functionality to support files on the user's system. // Blob returns a newly created object, the contents of the parameters in a given array series. new Blob([wbout], { type: 'application/octet-stream' }), // set the export file name 'sheetjs.xlsx' ) } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) } return wbout },