javascript - 无法以 Angular 7 导出 excel (xlsm) - 使用 spring boot 后端

标签 javascript angular typescript spring-boot filesaver.js

我有一个用于导出到 excel 功能的 Spring Boot Controller

问题是在下载 excel 后说文件已损坏并且永远无法打开。 代码有什么问题?我知道这与字符编码有关,因为当我通过 postman (使用保存文件功能)下载同一文件时,文件可以顺利打开。如果我打开 postman 格式和 Angular 格式,我会看到一些二进制字符的差异。

最佳答案

您的 exportAlluserData() 方法中的 responseType 值有误:

responseType: 'blob' as 'json'

将其替换为:responseType: 'arraybuffer'

关于javascript - 无法以 Angular 7 导出 excel (xlsm) - 使用 spring boot 后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59070976/

相关文章:

javascript - jQuery 1.7.2 AJAX 调用抛出 NS_ERROR_XPC_NOT_ENOUGH_ARGS 错误

javascript - 使用javascript在对象数组中查找值

javascript - 如何使用 Cloud Firestore 在 ionic 4 应用程序中获取数据

Angular:串联和并联组合 Observables

angular - 更新 Angular/ngrx reducer 中的嵌套状态结构

html - Angular 。在 flex 列表中拖放

javascript - 在 bootgrid 中禁用 'hide' 功能

javascript - Node.js 和 JSON : Accessing object properties

angular - 如何获取 Mat-Table 的实例,如果我们在组件中有多个表

Angular2,一个组件的多个 View ?