关于#excel#的问题,如何解决?

Vue3 导出文件为excel 代码如下:
export function excel(code,total,name,upInfo) {

axios({
    url: "/report/bb/exportExcel",
    method: "post",
    data: {
        csbs: code,
        pageIndex: 1,
        pageSize: total,
        parameterMap:    JSON.stringify(deleteKey(upInfo))
    },
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    responseType: "blob"
}).then(res => {
    const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
    const fileName = name
    if ('download' in document.createElement('a')) { // 不是IE浏览器
        const url = window.URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.style.display = 'none';
        link.href = url;
        link.setAttribute('download', fileName);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link); // 下载完成移除元素
        window.URL.revokeObjectURL(url); // 释放掉blob对象
    } else { // IE 10+
        window.navigator.msSaveBlob(blob, fileName);
    }
})

}

同样的代码 只有一个页面导出不带表头

img

这个页面带表头

img

两个是同样的页面 不同路由

有没有可能是接口返回的数据问题

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^