因项目需要,需要把Excel里面的数据整合处理一下,文件多,而且文件内容较大,所以希望实现自动化。问了下师兄,他介绍说ClosedXML比较好用。安装过程就不细说了,使用Visual Studio的NuGet一键安装即可。
ClosedXML就是一个类库,用于开发windows组件。它是在微软的类库OpenXML的基础上封装而成的,所以在实际项目中除了添加ClosedXML.dll引用,还需要添加DocumentFormat.OpenXML.dll的引用。当然,NuGet会检查依赖关系,帮你完成上面的添加引用步骤。ClosedXML的功能,引用官网的一句话介绍其功能:
ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).
废话不多说,讲讲具体怎么用。