C# 命名空间错误 OfficeOpenXML EPPlus

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17551095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 09:49:32  来源:igfitidea点击:

Namespace error OfficeOpenXML EPPlus

c#.netvisual-studiovisual-studio-2012epplus

提问by user99999991

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

我在 Visual Studio 2012 中设置 EPPlus 有困难。

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.

现在我尝试了 2 种不同的方法来设置 EPPlus。

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

我在我的文档中手动添加了一个 Project->Add Reference 到 Epplus.dll 文件。

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

我还尝试使用 NuGet 包管理器控制台: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?

我清楚地看到 EPPlus 已添加到我的项目中的 References,但未添加 OfficeOpenXML 的命名空间。如何使用 EPPlus 引用添加此命名空间?

采纳答案by Jon Skeet

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.

注意末尾的小写“M”和“L”。

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

我说的是仅基于示例代码......

回答by vivlong

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.

就我而言,我还在 Visual Studio 2012 中使用了 EPPlus,该项目是从 vs2005 升级的。在 Framework2.0 中。如果我将项目更改为 .Net framework 4.5,则重建成功。

回答by Jason Loki Smith

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.

我遇到了同样的问题,请检查您项目的目标框架(右键单击您的项目 -> 属性,检查“目标框架”)是否未设置为任何 .NET 框架 X“客户端配置文件”框架。客户端配置文件是您使用的任何框架的缩小版本。

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

关于 EPPlus,您的项目必须使用完整的框架,而不是任何“客户端配置文件”框架

回答by Spencer Sullivan

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

我只安装了DocumentFormat.OpenXml,尽管遵循网络上的其他来源,但参考不起作用。

I had to install, through NuGet, both DocumentFormat.OpenXmlAND EPPlusto get the reference to work.

我必须通过 NuGet 安装DocumentFormat.OpenXmlANDEPPlus才能使参考工作。

That fixed this for me.

那为我解决了这个问题。