如何在 python 中将工作簿对象转换为输出流

问题描述 投票:0回答:0

我想使用 python 将工作簿对象 () 转换为输出流。

这是我的 python 代码。

def main(inputblob: func.InputStream, outputblob: func.Out[BytesIO]):
logging.info(f"Python blob trigger function processed blob \n"
             f"Name: {inputblob.name}\n"
             f"file: {inputblob}\n"
             f"Blob Size: {inputblob.length} bytes")

    ...some code goes here...

today = date.today()
date_today = today.strftime("%m-%d-%y")
outputfile = "{}_COMPLETE_{}".format(date_today,input_file_name)

wb.save(outputfile)
output = BytesIO(wb)

outputblob.set(output)

这给出了一个错误。

执行“Functions.BlobTrigger”(失败,Id=291563d2-407c-4540-9471-9f49cbc74857,持续时间=77564ms) [2023-03-30T06:42:20.778Z] System.Private.CoreLib:执行函数时出现异常:Functions.BlobTrigger。 System.Private.CoreLib:结果:失败 异常:类型错误:需要一个类似字节的对象,而不是“工作簿” 堆栈:文件“C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python .9/WINDOWS/X64 zure_functions_worker\dispatcher.py”,第 452 行,在 _handle__invocation_request 中 call_result = await self._loop.run_in_executor( 文件“C:\Users\Asuni\AppData\Local\Programs\Python\Python39\li

python excel azure-functions outputstream
© www.soinside.com 2019 - 2024. All rights reserved.