1.使用xlsx-style是会出现以下报错

This relative module was not found:

* ./cptable in ./node_modules/xlsx-style/dist/cpexcel.js

修改vue.config.js

module.exports = {
    devServer: {
        port: 8080,   // 端口号
    },
    publicPath: './',
    productionSourceMap: false,
    configureWebpack: {
        //添加此配置
        externals: {
            './cptable': 'var cptable'
        }
    }
}

2.使用

import XLSX from 'xlsx'
import XLSXD from 'xlsx-style'
import FileSaver from 'file-saver'

function s2ab(s) {
    let buf = new ArrayBuffer(s.length);
    let view = new Uint8Array(buf);
    for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
    return buf;
}

var wb = XLSX.utils.table_to_book(‘此处为表格html’, { raw: true });
var sheet = wb.SheetNames[0];
var ws = wb.Sheets[sheet];
//修改样式
ws["A1"].s = {
        alignment: { horizontal: 'center', },
        font: { //修改字体和大小
              name: "宋体",
              sz: 10,
        },
        numFmt: "0.00"//格式化数字
}
var wbout = s2ab(XLSXD.write(wb, { bookType: 'xlsx', bookSST: true, type: 'binary' }));
 FileSaver.saveAs(new Blob([wbout], { type: 'application/ octet - stream' }), `表名.xlsx`)