Reputation: 113
I am trying to create an Excel and return it using an Azure function in Python. the excel is successfully generated inside the function but I am not sure how to return that Excel from the Azure function. I found a similar answer in C#
How do you return an xlsx file from an Azure function?
I am not able to convert it to Python using similar libraries.
Upvotes: 1
Views: 961
Reputation: 7483
You could refer to this answer, and use xlrd
for xlsx file.
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]}")
Upvotes: 2