Namespace error OfficeOpenXML EPPlus
Asked Answered
B

5

15

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?

Bovine answered 9/7, 2013 at 14:38 Comment(0)
E
22

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...

Endgame answered 9/7, 2013 at 14:42 Comment(4)
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!Bovine
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?Bovine
@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.Endgame
In my case I had to target the .Net framework 4 not the client profileWindom
P
9

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.

Pluri answered 14/2, 2017 at 16:14 Comment(1)
You save my dayZofiazoha
W
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

Waac answered 23/9, 2014 at 4:57 Comment(0)
F
0

In my case I also using EPPlus in Visual Studio 2012 which the project is upgrade from vs2005. in Framework2.0. If I changed the project to .Net framework 4.5 then it is rebuild success.

Fleischer answered 17/6, 2014 at 7:46 Comment(1)
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.Iyeyasu
S
0

The problem is that you need a reference to be able to use OpenOfficeXml, in this case it is EPPlus.

In your project open "Manage NuGet Packages...":

enter image description here

Install EPPlus:

enter image description here

This way you can easily build your project to use OfficeOpenXml.

Splanchnology answered 4/5, 2022 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.