Skip to content

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.

License

Notifications You must be signed in to change notification settings

Codeuctivity/ClosedXML

 
 

Repository files navigation

ClosedXML

.NET build and test NuGet Badge Donate

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.

This fork of ClosedXML adds Linux and MacOs support.

For more information see the wiki

Install ClosedXML via NuGet

To install ClosedXML, run the following command in the Package Manager Console

PM> Install-Package Codeuctivity.ClosedXML

What can you do with this?

ClosedXML allows you to create Excel files without the Excel application. The typical example is creating Excel reports on a web server.

Example:

using (var workbook = new XLWorkbook())
{
    var worksheet = workbook.Worksheets.Add("Sample Sheet");
    worksheet.Cell("A1").Value = "Hello World!";
    worksheet.Cell("A2").FormulaA1 = "=MID(A1, 7, 5)";
    workbook.SaveAs("HelloWorld.xlsx");
}

Example code writes list of poco objects to excel file:

public class ExcelWriter
{
    public static void WriteExcelFile(List<YourSpreadSheetRowPOCO> YourSpreadSheetRows, string file)
    {
        using var workbook = new XLWorkbook();
        workbook.AddWorksheet("WorkSheetNameShownInSpreadSheetSoftware").FirstCell().InsertTable<YourSpreadSheetRowPOCO>(YourSpreadSheetRows, false);
        workbook.SaveAs(file);
    }
}

Frequent answers

  • ClosedXML is not thread-safe. There is no guarantee that parallel operations will work. The underlying OpenXML library is also not thread-safe.

Developer guidelines

The OpenXML specification is a large and complicated beast. In order for ClosedXML, the wrapper around OpenXML, to support all the features, we rely on community contributions. Before opening an issue to request a new feature, we'd like to urge you to try to implement it yourself and log a pull request.

Please read the full developer guidelines.

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%