.net 使用 OpenXML 的 EPPlus 和 ClosedXML 库之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10501528/
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-09-03 16:24:21  来源:igfitidea点击:

What are the differences between the EPPlus and ClosedXML libraries for working with OpenXML?

.netopenxmloffice-2007closedxml

提问by llasarov

I'm trying to choose between ClosedXML, EPPlus, and possibly SpreadsheetLight. What reasons might I consider for picking one over the others?

我正在尝试在 ClosedXML、EPPlus 和可能的 SpreadsheetLight 之间进行选择。我可以考虑哪些原因而不是其他?

采纳答案by Berat Bilgin

Open-Source: Have you looked at EPPlus?

开源:你看过EPPlus吗?

Slogan: Create advanced Excel 2007/2010 spreadsheets on the server.

口号:在服务器上创建高级 Excel 2007/2010 电子表格。

License: GNU Library General Public License (LGPL).

许可证:GNU 库通用公共许可证 (LGPL)。

回答by Chris

I've been evaluating EPPlus, ClosedXML, and SpreadsheetLight over the past week. All three are really great libraries that make working with the extremely convoluted OpenXML a breeze. I've decided to go with EPPlus for the following reasons:

过去一周我一直在评估 EPPlus、ClosedXML 和 SpreadsheetLight。这三个都是非常棒的库,使使用极其复杂的 OpenXML 变得轻而易举。由于以下原因,我决定使用 EPPlus:

  • Initially, I was going to go with ClosedXML. It has great documentation and the object structure made a lot of sense to me. I have some charting requirements though and as of right now, ClosedXML doesn't have any charting functions.

  • Then I stumbled upon SpreadsheetLight which also has good docs and does support some charting. I also like the author's attitude and his commitment to his product. However, the project is built on top of the OpenXML 2.0 SDK, not 2.5, which is a deal breaker for me because I want to have the flexibility to work directly with OpenXML in the event that the library doesn't quite meet my needs. My project is targeting excel 2013 so I want to have the latest SDK to work with....Update! See ErrCode's comment below for additional info...

  • Finally, I came across EPPlus which has okay documentation and supports charting. It is has been downloaded far more times than the other two which gives me some security in knowing that others are using it and the community seems to be active around the project. They are also currently on beta 2 of version 4 which sounds promising from what others are saying. I'm also getting the gist that EPPlus has good performance (not that the others are necessarily bad) and the upcoming version 4 seems to be improving on that further.

  • 最初,我打算使用 ClosedXML。它有很好的文档,对象结构对我来说很有意义。我有一些图表要求,截至目前,ClosedXML 没有任何图表功能。

  • 然后我偶然发现了 SpreadsheetLight,它也有很好的文档并且支持一些图表。我也喜欢作者的态度和他对产品的承诺。但是,该项目建立在 OpenXML 2.0 SDK 之上,而不是 2.5,这对我来说是一个交易破坏者,因为我希望在库不能完全满足我的需求的情况下灵活地直接使用 OpenXML。我的项目面向 excel 2013,所以我想使用最新的 SDK。...更新!有关其他信息,请参阅下面的 ErrCode 评论...

  • 最后,我遇到了 EPPlus,它有不错的文档并支持图表。它的下载次数远多于其他两个,这让我知道其他人正在使用它,并且社区似乎对这个项目很活跃,这给了我一些安全感。他们目前也在第 4 版的 beta 2 上,从其他人的说法听起来很有希望。我还了解到 EPPlus 具有良好的性能(并不是说其他​​的就一定很差)并且即将推出的第 4 版似乎正在进一步改进。



Update

更新

Another very useful feature I've found included with EPPlus is how it exposes the XML for the various parts of the worksheet. If there's a feature that is not supported by EPPlus, you can still edit the XML (in some cases) to get the desired output. For example, if you have a pivot chart and want to enable multi-level labels, you can do the following:

我发现 EPPlus 包含的另一个非常有用的功能是它如何为工作表的各个部分公开 XML。如果 EPPlus 不支持某个功能,您仍然可以编辑 XML(在某些情况下)以获得所需的输出。例如,如果您有一个数据透视图并希望启用多级标签,您可以执行以下操作:

    private void EnableMultiLevelLabels(ExcelChart chart)
    {   
        var element = chart.ChartXml.GetElementsByTagName("c:catAx")[0];
        if (element == null)
            return;

        var multiLevelLabelNode = element.AppendChildElementNode("c:noMultiLvlLbl");
        if (multiLevelLabelNode != null)
            multiLevelLabelNode.AppendNodeAttribute("val", "0");
    }

回答by Vincent Tan

SpreadsheetLight, and it runs internally on Open XML SDK. MIT License. Disclaimer: I wrote SpreadsheetLight.

SpreadsheetLight,它在 Open XML SDK 内部运行。麻省理工学院许可证。免责声明:我写了SpreadsheetLight。