C# 产生 EXCEL 的第三方套件评估
标题 | Microsoft.Office.Interop.Excel | NPOI | EPPlus | ClosedXml | 描述This an assembly you can use for Excel 2013/2016/2019 COM interop, generated and signed by Microsoft.a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API.官网官网官网官网官网依赖性需要安装 Microsoft Office无依赖性无依赖性无依赖性性能最慢速度快速度快速度慢,ClosedXML可能不适合大量资料,存档时间也是另外一个问题,我测试产生500页A4(大约2万多Rows)光存档就花了200秒以上共享性最差,因官方Office 于设计时被定义为个人软体,所以该Library对于多人同时操作与共享的支援性较差,对于一个Web Service而言,容易造成Excel程序无法被正确释放,Server的记忆体被大量占用,进而导致Server的不稳定。不支援大资料量以及多sheet的汇出最佳,可大量资料操作且吃记忆体较小记忆体使用量较高,30栏位 x 10万笔资料的 excel 在过程中,closedxml 用了约1G的记忆体,epplus 却不到 400M兼容性差,不同的office版本之间可能会有兼容问题NPOI目前支援.xls与.xlsx,但是两种格式的文件于NPOI内部的元件设计并不相同。若开发的系统欲同时支援两种格式,则必须撰写两份不同的程式码来进行文件的产出。仅支援.xlsx的格式,不支援2003版的Excel最佳,档案相容性测试又比NPOI及EPPlus好商业授权需要购买 Microsoft Office商用需NPOI 付费授权EPPlus5.0以上版本要商业授权码MIT 授权
结论:
目前最佳免费方案是 EPPlus 4.5.3
基础的编辑 4.X 完全可胜任。