在ClosedXML中的命名空间是什么 [英] What is the namespace for in ClosedXML

查看:145
本文介绍了在ClosedXML中的命名空间是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#中尝试了一个关闭xml(用于创建Excel 2007/2010文件)的简单示例。



我的代码行是:

Im trying a simple example of closed xml (used to create Excel 2007/2010 files) in c#.

my code line is:

var workbook = new XLWorkbook();



我在此声明中收到如下警告:


Im getting warning on this statement as follows:

the type or namespace XLWorkbook cannot be found(are you missing using a directive or an assembly reference ?)

我在bin文件夹中添加了ClosedXML.dll,DocumentFormat.OpenXml.dll。

我的Compelete代码如下:

I have added ClosedXML.dll,DocumentFormat.OpenXml.dll in bin folder.
My Compelete code is as follows:

using System;
using ClosedXML.Excel;

public partial class Demo01 : System.Web.UI.Page
{
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
               var workbook = new XLWorkbook();
               var worksheet = workbook.Worksheets.Add("Sample Sheet");
               worksheet.Cell("A1").Value = "Hello World!";
               workbook.SaveAs("HelloWorld.xlsx");
        }
}



请帮帮我.. !!


Please help me..!!

推荐答案

什么你的意思是我添加了ClosedXML.dll?你没有添加DLL(DLL在.NET中并不重要,不再是某些可执行模块的命名约定,.NET使用程序集 modules ),您需要引用程序集来构建依赖于ClosedXML或其他任何东西的程序集。如果这是Visual Studio,则项目树中有添加引用项,它是解决方案资源管理器树视图的一部分。如果你以其他方式构建,总会有引用程序集的选项。



命名空间是 ClosedXML ,在您的情况下, ClosedXML.Excel 。你怎么可能错过命名空间?请参阅:

http://closedxml.codeplex.com/SourceControl/changeset / view / 76880#1045401 [ ^ ]。



命名空间不添加任何模块化或类似的东西;他们只向顶级类型引入扩展的完全限定命名。您可以使用使用子句或根本不使用它:它不能更改程序集依赖项中的任何内容。



< dd> -SA
What do you mean "I have added ClosedXML.dll"? You don't "add DLL" (DLL is no really significant in .NET, no more then a naming convention for some of executable modules, .NET operates with assemblies and modules), you need to reference assembly to build an assembly dependent on ClosedXML or anything else. If this is Visual Studio, you have the "Add Reference" item in your project tree, a part of "Solution Explorer" tree view. If you build in other ways, there are always the options to reference assemblies.

The namespace is ClosedXML, in your case, ClosedXML.Excel. How could you possibly miss the namespace? Please see:
http://closedxml.codeplex.com/SourceControl/changeset/view/76880#1045401[^].

Namespace does not add any modularity or something like that; they only introduce extended "fully-qualified" naming to top-level types. You can use using clause or not using it at all: it cannot change anything in assembly dependencies.

—SA


你缺少程序集的引用,只需添加ClosedXML.dllit就可以了
you are missing the reference of the assemby,just add ClosedXML.dllit will works


你错过了对ClosedXML.dll或DocumentFormat.OpenXml.dll的引用



请参阅文档页面
You're missing a reference to ClosedXML.dll or DocumentFormat.OpenXml.dll

See the requirements section at the top of the documentation page.


这篇关于在ClosedXML中的命名空间是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆