Namespace error OfficeOpenXML EPPlus

60,852

Solution 1

I believe this is just a problem of casing. This:

using OfficeOpenXML;

should be:

using OfficeOpenXml;

Note the lower case "M" and "L" at the end.

I say that based only on the sample code...

Solution 2

I had only installed DocumentFormat.OpenXml and the reference would not work despite following other sources on the net.

I had to install, through NuGet, both DocumentFormat.OpenXml AND EPPlus to get the reference to work.

That fixed this for me.

Solution 3

I had the same issue, check that your project's Target Framework (Right click on your project -> Properties, check "Target framework") is not set to any .NET framework X "Client Profile" frameworks. Client profile is a minified version of whatever framework you are using.

With regards to EPPlus, your project must be using the full framework and not any "Client Profile" frameworks

Share:
60,852
user99999991
Author by

user99999991

const all the things

Updated on April 14, 2020

Comments

  • user99999991
    user99999991 about 4 years

    I'm having difficulty setting up EPPlus in Visual Studio 2012.

    using OfficeOpenXML;
    The type or namespace name 'OfficeOpenXML' could not be found(are you missing a using directive or an assembly reference?)
    

    Now I tried 2 different ways to set EPPlus up.

    I manually added a Project->Add Reference to the Epplus.dll file in my documents.

    I also tried to use NuGet package manager console: PM> Install-Package EPPlus

    I clearly see EPPlus is added to the References in my project, but the namespace for OfficeOpenXML is not added. How do I add this namespace with the EPPlus reference?

  • user99999991
    user99999991 almost 11 years
    Welp I feel like a horses arse now. Thanks so much! I was getting so frustrated. I was looking at that same code and was like nothing is different!
  • user99999991
    user99999991 almost 11 years
    If you don't mind me asking @Jon, if I save this project to something like TFS or transfer it to another machine with another installation of VBS2012 - do I need to readd the .dll reference manually or will it know because I did it already in the project?
  • Jon Skeet
    Jon Skeet almost 11 years
    @user2229804: Using NuGet, you can just strip the package itself, and whoever opens it will be able to fetch the dependency. Otherwise, if you put the DLL into source control in the right relative location, it should be fine that way too.
  • meda
    meda almost 11 years
    In my case I had to target the .Net framework 4 not the client profile
  • Missy
    Missy almost 7 years
    I had this problem persistently and did all the recommended solutions. I uninstalled and reinstalled EPPlus and still no luck. Finally, I opened the EPPlus sample and ran it and it worked fine. When I went back to the project that was giving me trouble and it worked. I just thought I'd throw that out there after 4 hours of trial and error.
  • Viet Nguyen
    Viet Nguyen over 6 years
    You save my day