数据库中样式与导出excel中样式不一致
解决办法:
在导出方法中加入参数 raw: true
// 纯前端导出Excel表格 handleExport (id, name, List) { // .table要导出的是哪一个表格 this.operation = false; this.$nextTick(() => { this.operationCheck = false; this.$nextTick(() => { let table = document.querySelector(id).cloneNode(true); table.removeChild(table.querySelector('.el-table__fixed-right')) table.removeChild(table.querySelector('.el-table__fixed-right-patch')) const wb = XLSX.utils.table_to_book(table, {sheet: 'SHEETJS', raw: true}); this.setExlStyle(wb['Sheets']['SHEETJS'], List); const wbOut = XLSXS.write(wb, { bookType: 'xlsx', bookSST: true, type: 'buffer' }); try { FileSaver.saveAs( new Blob([wbOut], {type: 'application/octet-stream'}), name + '.xlsx' ); } catch (e) { if (typeof console !== 'undefined') console.log(e, wbOut); } this.operation = true; this.operationCheck = true; return wbOut; }) }) },
加入该参数后导出效果如下: