我有 Rails API 和 Angular 4 应用程序。拥有 Excel 报告的用户,这些报告仅适用于经过身份验证的用户。
Rails API 将包含报告数据。 Angular 应用程序应从 Rails API 获取数据并下载 Excel 文件。
请给我建议如何实现这个?感谢您的回答。
最佳答案
您可以使用 API 下载 Excel 文件。为此,您只需设置特定 header 即可下载 Excel 文件。这里是
def show
respond_to do |format|
format.html { # render normal show here }
format.xls { # render excel file here }
end
end
并制作 http://localhost:3000/data/5.xls来自 Angular 应用程序的请求将提示下载 Excel 文件
关于javascript - 如何使用 Angular4 和 Rails API 下载 Excel 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50738642/