0

Is it possible to add the reference for ExcelDataReader and ExcelDataset in Azure functions? I uploaded dll file of NuGet packages (exceldatareader.3.4.0.nupkg) to the program. But I'm not sure how actually it has to be used. Can anyone help me to achieve this.

#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;

Thank you.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
Sapna
  • 21
  • 4
  • what the error or difficulty you faced, what are you tried – Ajay2707 Aug 01 '18 at 12:36
  • please see the whole process - http://www.dotnetfunda.com/articles/show/3489/read-a-excel-blob-file-using-excel-data-reader-in-azure – Ajay2707 Aug 01 '18 at 12:51
  • I have added the reference I tried to add in the question above – Sapna Aug 01 '18 at 12:56
  • check this - https://stackoverflow.com/questions/27634477/using-exceldatareader-to-read-excel-data-starting-from-a-particular-cell – Ajay2707 Aug 01 '18 at 13:00
  • @ajay2707 That article is regarding console application right. I'm able to complete my task in the console application. I want to implement the same using the Azure functions. using ExcelDataReader; throws error saying, 'reference is missing'. – Sapna Aug 01 '18 at 13:04

1 Answers1

1

To install packages for Azure functions on portal, we need to create dependencies file under function folder. Click View files on the right of function panel, Add file according to runtime.

If your function runtime is ~1, create project.json with following content.

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

If your function runtime is ~2, create function.proj as below.

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

After file created, assemblies will be added to function host environment. Also need to remove unnecessary #r "exceldatareader" or you will got error.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61