前端导出excel及文件流传后端

前端导出excel

res = await axios('url',{responseType: 'blob'})
name=`${state.queryData.attendanceTime}统计.xlsx`

const url = window.URL.createObjectURL(new Blob([res],{type: "application/vnd.ms-excel"}))
const a = document.createElement('a');
a.href=url;
a.setAttribute('download',name);
a.click();
a.remove();

给后端传文件流

let formData = new FormData()
formData.append('file', file.file)//file.file就是文件流blob
let res=await upload(formData)

你可能感兴趣的:(前端,excel)