C# 有没有人有 .Net Excel IO 组件基准测试?

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

Does anyone have .Net Excel IO component benchmarks?

提问by Samuel Hyman

I'm needing to access Excel workbooks from .Net. I know all about the different ways of doing it (I've written them up in a blog post), and I know that using a native .Net component is going to be the fastest. But the question is, which of the components wins? Has anybody benchmarked them? I've been using Syncfusion XlsIO, but that's very slow for some key operations (like deleting rows in a workbook containing thousands of Named ranges).

我需要从 .Net 访问 Excel 工作簿。我知道所有不同的实现方式(我已经在博客文章中写过),而且我知道使用原生 .Net 组件将是最快的。但问题是,哪个组件获胜?有没有人对他们进行过基准测试?我一直在使用 Syncfusion XlsIO,但是对于某些关键操作(例如删除包含数千个命名范围的工作簿中的行)来说这非常慢。

采纳答案by Samuel Hyman

I haven't done any proper benchmarks, but I tried out several other components,and found that SpreadsheetGearwas considerably faster than XlsIO which I was using before. I've written up some of my findings in this post

我没有做过任何适当的基准测试,但我尝试了其他几个组件,发现SpreadsheetGear比我之前使用的 XlsIO 快得多。我在这篇文章中写下了我的一些发现

回答by Samuel Hyman

Can't help you with your original question, but are you aware that you can access Excel files using an OleDbConnection, and therefore treat it as a database? You can then read worksheets into a DataTable, perform all the changes you need to the data in your application, and then save it all back to the file using an OleDbConnection.

无法帮助您解决最初的问题,但您是否知道可以使用 OleDbConnection 访问 Excel 文件,因此将其视为数据库?然后,您可以将工作表读入 DataTable,对应用程序中的数据执行所需的所有更改,然后使用 OleDbConnection 将其全部保存回文件。

回答by CAD bloke

Yes but I'm not going to publish them both out of a courtesy to Syncfusion (they ask you not to publish benchmarks), because I'm not an experienced tester so my tests are probably somewhat flawed but mostly because what you actually benchmark makes a huge difference to who wins and by how much.

是的,但出于对 Syncfusion 的礼貌,我不会发布它们(他们要求您不要发布基准测试),因为我不是经验丰富的测试人员,所以我的测试可能有些缺陷,但主要是因为您实际进行了基准测试谁获胜以及获胜多少的巨大差异。

I took one of their "performance" examples and added the same routine in EPPlus to compare them. XLSIO was around 15% faster with just straightforward inserts, depending on the row/column ratio (I tried a few), memory usage seemed very similar. When I added a routine that, after all the rows were added, deleted every 10th row and then inserted a new row 2 rows up from that - XLSIO was significantly slower in that circumstance.

我拿了他们的一个“性能”示例,并在 EPPlus 中添加了相同的例程来比较它们。XLSIO 仅通过简单的插入就快了 15% 左右,这取决于行/列比率(我尝试了一些),内存使用情况似乎非常相似。当我添加一个例程时,在添加所有行后,每 10 行删除一次,然后插入一个新行 2 行 - 在这种情况下,XLSIO 明显变慢。

A generic benchmark is pretty-much useless to you. You need to try them against each other in the specific scenarios you use.

通用基准测试对您来说几乎没有用处。您需要在您使用的特定场景中相互尝试。

I have been using EPPlus for a few years and the performance has been fine, I don't recall shouting at it.

我已经使用 EPPlus 几年了,性能很好,我不记得对它大喊大叫。

More worthy of your consideration is the functionality, support (Syncfusion have been good, in my experience), Documentation, access to the source code if that is important, and - importantly - how much sense the API makes to you, the syntax can be quite different. eg. Named Styles

更值得您考虑的是功能、支持(Syncfusion 一直很好,以我的经验)、文档、对源代码的访问(如果这很重要),以及 - 重要的是 - API 对您有多大意义,语法可以很不一样。例如。命名样式

XLSIO

XLSIO

headerStyle.BeginUpdate();
workbook.SetPaletteColor(8, System.Drawing.Color.FromArgb(255, 174, 33));
headerStyle.Color = System.Drawing.Color.FromArgb(255, 174, 33);
headerStyle.Font.Bold = true;
headerStyle.Borders[ExcelBordersIndex.EdgeLeft]  .LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeRight] .LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeTop]   .LineStyle = ExcelLineStyle.Thin;
headerStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
headerStyle.EndUpdate();

EPPlus

EPPlus

ExcelNamedStyleXml headerStyle = xlPackage.Workbook.Styles.CreateNamedStyle("HeaderStyle");
headerStyle.Style.Fill.PatternType = ExcelFillStyle.Solid; // <== needed or BackgroundColor throws an exception
headerStyle.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(255, 174, 33));
headerStyle.Style.Font.Bold = true;
headerStyle.Style.Border.Left.Style   = ExcelBorderStyle.Thin;
headerStyle.Style.Border.Right.Style  = ExcelBorderStyle.Thin;
headerStyle.Style.Border.Top.Style    = ExcelBorderStyle.Thin;
headerStyle.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;