如何从 Azure 函数返回 xlsx 文件? [英] How do you return an xlsx file from an Azure function?

查看:18
本文介绍了如何从 Azure 函数返回 xlsx 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有人尝试过.我无法重现他们的结果.乐于使用任何语言.我可以从 HTTP 触发器创建一个 xlsx.我想从另一个 HTTP 触发器返回该文件.

I've seen some people try. I could not reproduce their results. Happy to use any language. I can create an xlsx from an HTTP Trigger. I want to return that file from another HTTP Trigger.

推荐答案

如果你已经生成了文件,返回它只是创建一个带有附件的 HTTP 响应:

If you have already generated the file, returning it is just creating an HTTP response with an attachment:

var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(xlsxBytes);
result.Content.Headers.ContentDisposition = 
    new ContentDispositionHeaderValue("attachment") { FileName = "Book1.xlsx" };
result.Content.Headers.ContentType = 
    new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
return result;

这篇关于如何从 Azure 函数返回 xlsx 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆