我正在尝试创建 Excel 并使用 Python 中的 Azure 函数返回它。 excel 已在函数内成功生成,但我不确定如何从 Azure 函数返回该 Excel。我在 C# 中找到了类似的答案
How do you return an xlsx file from an Azure function?
我无法使用类似的库将其转换为 Python。
最佳答案
可以引用这个answer ,并使用 xlrd
作为 xlsx 文件。
import logging
import azure.functions as func
import xlrd
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
with xlrd.open_workbook('test.xlsx') as wb:
with wb.get_sheet(1) as sheet:
return func.HttpResponse(f"{[row for row in sheet]}")
关于python-3.x - 从 Python 中的 HTTP 触发的 azure 函数返回 excel 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67250469/