您如何 return 来自 Azure 函数的 xlsx 文件?

How do you return an xlsx file from an Azure function?

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

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

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;