我能够使用 python pandas 生成一个 excel:
df = pd.DataFrame(columns =["test"])
writer = pd.ExcelWriter(f'{basepath}/Summary.xlsx', engine='xlsxwriter')
df.to_excel(writer,engine='openpyxl',sheet_name= 'Sample')
writer.save()
但是,当我尝试使用带有 HTTP 触发器的 azure 函数来触发它时,下载的 excel 会显示:
以下是我一直在使用的代码:
df = pd.DataFrame(columns =["test"])
writer = pd.ExcelWriter(f'{basepath}/Summary.xlsx', engine='xlsxwriter')
df.to_excel(writer,engine='openpyxl',sheet_name= 'Sample')
writer.save()
response = func.HttpResponse(body=None,headers={'Content-Disposition':'attachment; filename='f'{basepath}/Summary.xlsx'}, mimetype='application/vnd.ms-excel')
return response