Home » excel » f# – Excel Type Provider has error – it needs an assembly "Excel.dll"

f# – Excel Type Provider has error – it needs an assembly "Excel.dll"

Posted by: admin March 9, 2020 Leave a comment

Questions:

So, I started with this code:

open System
open System.IO
open FSharpx
open Excel

module ExcelManipulation =

    type BoyICantWaitToUseThis = ExcelFile< @"C:\Users\sean.newham\Documents", "Sheet1", true>
    let example = new BoyICantWaitToUseThis()

…but it doesn’t compile because I need an “Excel.dell, Version=2.1.0.0…”, I didn’t know which Excel.dll that was, so I tried including the Excel Data Reader, which has a dll called “Excel.dll”, but alas, this does not appear to have removed the error message.

Any idea what I need here and where I could get it from?
Thanks in advance

How to&Answers:

It appears that until about 5 days ago (see here), the excel type provider had a dependency on having Office installed with the office interop files. The newer version depends on the Excel Data Reader.

If you look at the pull request for that change here, you see that the type provider used to reference

<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

See here for instructions on how to install that.

As an added bonus, you can look at the unit tests in that link for details on how to use the provider.

Answer:

I was stuck at this same point trying to use FSharpx.TypeProviders.Excel. I switched to ExcelProvider and it worked out-of-the-nuget-box:

http://fsprojects.github.io/ExcelProvider/