如何使用C#在Azure函数中添加ExcelDataReader和Excel数据集的依赖项

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

是否可以在Azure函数中添加ExcelDataReaderExcelDataset的引用?我上传了NuGet包的dll文件(exceldatareader.3.4.0.nupkg)到程序中。但我不确定它实际上是如何使用的。任何人都可以帮助我实现这一目标。

#r "Microsoft.WindowsAzure.Storage"
#r "System.IO"
#r "System.Data"
#r "exceldatareader" //*I'm not able to add this reference|*
using System;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Auth;
using ExcelDataReader;
using System.Data;

谢谢。

c# excel azure azure-functions
1个回答
1
投票

要在门户上安装Azure功能包,我们需要在功能文件夹下创建依赖项文件。根据运行时单击功能面板右侧的View filesAdd文件。

如果函数运行时为~1,请使用以下内容创建project.json

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "ExcelDataReader.DataSet": "3.4.0"
      }
    }
   }
} 

如果函数运行时为~2,请按如下所示创建function.proj

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="ExcelDataReader.DataSet" Version="3.4.0"/>
    </ItemGroup>
</Project>

创建文件后,程序集将添加到功能主机环境中。还需要删除不必要的#r "exceldatareader"或你会得到错误。

© www.soinside.com 2019 - 2024. All rights reserved.