js导出的excel文件无法打开/打开乱码,excel无法打开xxx.xlsx因为文件格式或文件扩展无效

excel无法打开xxx.xlsx因为文件格式或文件扩展无效

使用 a 标签导出这里就不细说了,直接说上述问题解决方案

在调用导出接口的时候加上两个参数

responseType: "blob"

responseEncoding: "utf8"

javascript 复制代码
export function test(data) {
  return util({
    url: '/test',
    method: 'POST',
    data,
    responseType: "blob",  //代表请求 blob数据格式
    responseEncoding: "utf8" // 使用UTF-8编码
  })
}
相关推荐
子兮曰8 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
吴仰晖8 小时前
使用github copliot chat的源码学习之Chromium Compositor
前端
1024小神8 小时前
github发布pages的几种状态记录
前端
不像程序员的程序媛10 小时前
Nginx日志切分
服务器·前端·nginx
Daniel李华10 小时前
echarts使用案例
android·javascript·echarts
北原_春希10 小时前
如何在Vue3项目中引入并使用Echarts图表
前端·javascript·echarts
JY-HPS10 小时前
echarts天气折线图
javascript·vue.js·echarts
尽意啊10 小时前
echarts树图动态添加子节点
前端·javascript·echarts
吃面必吃蒜10 小时前
echarts 极坐标柱状图 如何定义柱子颜色
前端·javascript·echarts
O_oStayPositive10 小时前
Vue3使用ECharts
前端·javascript·echarts