问题描述
我正在使用 Angular 9 和 OfficeJS 为 Excel 桌面应用程序(2016 及更高版本)开发 Excel 插件。 我有一个功能,在服务器上上传 xlsx 文件(保存为 blob)后,我必须以 xlsx 格式下载文件。我收到一个 Blob 响应正文,并使用此 Blob 响应通过 FileSaver 包下载 XLSX 文件。
在 Web(Google Chrome 和 Microsoft Edge)上使用 Office 365(Excel) 时,这工作正常,但是当我尝试使用相同的解决方案在 Windows 操作系统上的 Office 365(Excel) 本机桌面应用程序上下载文件时,我得到了以下错误:
SEC7134:资源 'blob:https://localhost:4200/0d57e7c9-0a2f-4a0c-82e1-2ae13ecdb74f' 不是 允许加载。
getSpreadSheet(fileName: string){
return this.httpClient.get(this.baseUrl + '/spreadsheets/' + fileName + '/download',{
headers: new HttpHeaders().set('Authorization',`Bearer ${this.token}`),responseType: 'blob',observe: 'response'
});
}
downloadFile(fileName: string) {
this.downloadingFile = true;
this.someService.getSpreadSheet('test2-mds.xlsx').subscribe((response) => {
const blob = response.body;
this.saveFile(blob);
});
}
saveFile(blob: Blob) {
FileSaver.saveAs(blob,'test2-mds.xlsx');
// download(blob,'test2-mds.xlsx','text/plain');
}
我附上了负责下载文件的代码。我还尝试使用“downloadjs”库并在使用 Office Web 时在桌面应用程序上遇到相同的错误。 配置如下: enter image description here
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)