-
什么是Closed Xml
-
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).
-
哪里下载
- Please refer to https://github.com/ClosedXML/ClosedXML to download the latest code
-
如何使用
- How to create a simple excel sheet file
The sample code demonstrate how to create a very simple excel sheet file. First, you need to create a workbook--XLWorkbook , then add a new sheet, then set value to cell: ‘A1’, then save to a specific path.public void Create(String filePath) { var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Sample Sheet"); worksheet.Cell("A1").Value = "Hello World!"; workbook.SaveAs(filePath); }
- 2. How to create basic table:
public void Create(string filePath) { // Creating a new workbook var wb = new XLWorkbook(); //Adding a worksheet var ws = wb.Worksheets.Add("Contacts"); //Adding text //Title ws.Cell("B2").Value = "Contacts"; //First Names ws.Cell("B3").Value = "FName"; ws.Cell("B4").Value = "John"; ws.Cell("B5").Value = "Hank"; ws.Cell("B6").Value = "Dagny"; //Last Names ws.Cell("C3"