azure - 从 Azure Function App 加载 *.xlsb 文件

标签 azure azure-functions

我需要从 Azure Function App 加载 *.xlsb 文件,有相应的工具或解决方案吗?

以下不支持*.xlsb:

https://github.com/ExcelDataReader/ExcelDataReader

https://github.com/OfficeDev/Open-Xml-Sdk

以下内容不是免费的:

https://www.easyxls.com/manual/basics/convert-xlsb-to-xlsx.html

有什么想法吗?

更新

必须是 C# 语言

最佳答案

我创建一个简单的 xlsx 文件并向其中写入一些数据,然后将其另存为 xlsb 文件。接下来,我使用了pyxlsb在Python中打包即可读取成功,如下图。

enter image description here

>>> from pyxlsb import open_workbook
>>> wb = open_workbook('readxlsb/test.xlsb')
>>> sheet = wb.get_sheet(1)
>>> [ row for row in sheet.rows()]
[[Cell(r=0, c=0, v='A'), Cell(r=0, c=1, v=1.0), Cell(r=0, c=2, v=4.0)], [Cell(r=1, c=0, v='B'), Cell(r=1, c=1, v=2.0), Cell(r=1, c=2, v=5.0)], [Cell(r=2, c=0, v='C'), Cell(r=2, c=1, v=3.0), Cell(r=2, c=2, v=6.0)]]

它也适用于我的函数应用程序,如下代码和图所示。

import logging

import azure.functions as func
from pyxlsb import open_workbook

def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    with open_workbook('readxlsb/test.xlsb') as wb:
        with wb.get_sheet(1) as sheet:
            return func.HttpResponse(f"{[row for row in sheet]}")

enter image description here

希望有帮助。

<小时/>

更新:

恐怕所有可以解析 xlsb 文件的 nuget 包都需要 Offical Suits 的 native 组件,但您无法在 Azure Function App 中安装 Offical Suits。所以我的建议是尝试安装ironpython从 Nuget 并使用 pyxlsb 从 C# 调用它来执行此操作。

此外,您还可以使用 HTTP 触发器或其他服务创建另一个函数来解析 xlsb 文件,以将 JSON 结果响应到当前的 C# 函数。

关于azure - 从 Azure Function App 加载 *.xlsb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57482950/

相关文章:

node.js - Azure Function 如何根据命令启动更大的 Node.js 应用程序

azure - 使用 Bicep 创建新订阅

Azure 自定义策略,仅允许在 ASE 上创建 Azure Functions

reactjs - React SPA 在开发机器上工作,但只有一级路由在 Azure 上工作

c# - .Net 可移植类库和 Microsoft.WindowsAzure.Mobile.Service.EntityData

azure - 使用 SDK 在 Blazor 服务器应用程序中运行 Office 365 图形 API 查询

javascript - Azure移动服务成功回调 `push.apns.send`

azure - VS 2019 更新后运行 azure 函数时出现调试配置文件不存在错误

azure - 创建新的 Azure Function App 时,在什么情况下应选择 Windows 以外的操作系统?

c# - 未使用“Autofac.Core.Activators.Reflection.DefaultConstructorFinder”找到任何构造函数