Convert Figma logo to code with AI

JanKallman logoEPPlus

Create advanced Excel spreadsheets using .NET

3,776
1,189
3,776
453

Top Related Projects

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.

Open XML SDK by Microsoft

Lightweight and fast library written in C# for reading Microsoft Excel files

Quick Overview

EPPlus is a .NET library that allows developers to read, write, and manipulate Excel 2007/2010 XLSX files without requiring Microsoft Office to be installed. It provides a comprehensive API for working with spreadsheets, including features like formula calculation, styling, charts, and more.

Pros

  • High performance and efficient memory usage
  • Extensive feature set covering most Excel functionalities
  • Active development and community support
  • Compatible with .NET Framework, .NET Core, and .NET Standard

Cons

  • Licensing changes in recent versions (now requires a commercial license for some use cases)
  • Learning curve can be steep for complex operations
  • Limited support for older Excel file formats (XLS)
  • Some advanced Excel features may not be fully supported

Code Examples

Creating a new workbook and adding data:

using OfficeOpenXml;

using (var package = new ExcelPackage())
{
    var worksheet = package.Workbook.Worksheets.Add("Sheet1");
    worksheet.Cells["A1"].Value = "Hello";
    worksheet.Cells["B1"].Value = "World";
    package.SaveAs(new FileInfo("output.xlsx"));
}

Reading data from an existing Excel file:

using OfficeOpenXml;

using (var package = new ExcelPackage(new FileInfo("input.xlsx")))
{
    var worksheet = package.Workbook.Worksheets[0];
    var cellValue = worksheet.Cells["A1"].Value;
    Console.WriteLine($"Value in A1: {cellValue}");
}

Adding a formula to a cell:

using OfficeOpenXml;

using (var package = new ExcelPackage())
{
    var worksheet = package.Workbook.Worksheets.Add("Sheet1");
    worksheet.Cells["A1"].Value = 10;
    worksheet.Cells["A2"].Value = 20;
    worksheet.Cells["A3"].Formula = "SUM(A1:A2)";
    package.SaveAs(new FileInfo("output.xlsx"));
}

Getting Started

  1. Install the EPPlus NuGet package:

    dotnet add package EPPlus
    
  2. Add the following using statement to your C# file:

    using OfficeOpenXml;
    
  3. If using .NET Core or .NET 5+, add this line before using EPPlus:

    ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
    
  4. Create an ExcelPackage object and start working with Excel files:

    using (var package = new ExcelPackage())
    {
        var worksheet = package.Workbook.Worksheets.Add("Sheet1");
        // Add your Excel operations here
        package.SaveAs(new FileInfo("output.xlsx"));
    }
    

Competitor Comparisons

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.

Pros of ClosedXML

  • Free and open-source, with no licensing restrictions
  • More intuitive API, closer to Excel's object model
  • Better support for older Excel file formats (xls)

Cons of ClosedXML

  • Slower performance for large datasets compared to EPPlus
  • Less comprehensive documentation and community support
  • Fewer advanced features for complex Excel operations

Code Comparison

ClosedXML:

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

EPPlus:

using (var package = new ExcelPackage())
{
    var worksheet = package.Workbook.Worksheets.Add("Sample Sheet");
    worksheet.Cells["A1"].Value = "Hello World!";
    package.SaveAs(new FileInfo("HelloWorld.xlsx"));
}

Both libraries offer similar functionality for basic Excel operations, but their APIs differ slightly. ClosedXML's approach is more intuitive for developers familiar with Excel's object model, while EPPlus provides a more streamlined API for certain operations.

Open XML SDK by Microsoft

Pros of Open-XML-SDK

  • More comprehensive support for Office Open XML formats (Word, Excel, PowerPoint)
  • Official Microsoft SDK, ensuring long-term support and compatibility
  • Offers greater flexibility and control over document structure

Cons of Open-XML-SDK

  • Steeper learning curve due to lower-level API
  • Requires more code to perform common operations
  • Less intuitive for simple Excel-specific tasks

Code Comparison

EPPlus:

using (var package = new ExcelPackage())
{
    var worksheet = package.Workbook.Worksheets.Add("Sheet1");
    worksheet.Cells["A1"].Value = "Hello, World!";
    package.SaveAs(new FileInfo("output.xlsx"));
}

Open-XML-SDK:

using (var spreadsheet = SpreadsheetDocument.Create("output.xlsx", SpreadsheetDocumentType.Workbook))
{
    var workbookPart = spreadsheet.AddWorkbookPart();
    workbookPart.Workbook = new Workbook();
    var worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
    worksheetPart.Worksheet = new Worksheet(new SheetData());
    var sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();
    var row = new Row { RowIndex = 1 };
    var cell = new Cell { CellReference = "A1", DataType = CellValues.String, CellValue = new CellValue("Hello, World!") };
    row.AppendChild(cell);
    sheetData.AppendChild(row);
}

Lightweight and fast library written in C# for reading Microsoft Excel files

Pros of ExcelDataReader

  • Lightweight and focused solely on reading Excel files
  • Supports both .xls and .xlsx formats
  • No external dependencies required

Cons of ExcelDataReader

  • Limited to reading Excel files; cannot create or modify spreadsheets
  • Less feature-rich compared to EPPlus
  • May require additional libraries for advanced data manipulation

Code Comparison

ExcelDataReader:

using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
    var result = reader.AsDataSet();
    // Process data from result
}

EPPlus:

using (var package = new ExcelPackage(new FileInfo(filePath)))
{
    var worksheet = package.Workbook.Worksheets[0];
    var value = worksheet.Cells["A1"].Value;
    // Manipulate data or create new spreadsheet
}

ExcelDataReader is more straightforward for simple reading tasks, while EPPlus offers more comprehensive Excel manipulation capabilities. ExcelDataReader is ideal for projects that only need to extract data from Excel files, whereas EPPlus is better suited for applications requiring both reading and writing Excel files with advanced formatting and calculation features.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

EPPlus

This repository has moved to https://github.com/EPPlusSoftware/EPPlus.

The code in this archive represents the final version of EPPlus under LGPL. There will be no more activity here.

EPPlus will from version 5 switch license from LGPL to Polyform Noncommercial 1.0.0 license.
With the new license EPPlus is still free to use in some cases, but will require a commercial license to be used in a commercial business.

More information on the license change on our website


Create advanced Excel spreadsheets using .NET, without the need of interop.

EPPlus is a .NET library that reads and writes Excel files using the Office Open XML format (xlsx). EPPlus has no dependencies other than .NET.  

EPPlus supports:

  • Cell Ranges
  • Cell styling (Border, Color, Fill, Font, Number, Alignments)
  • Data validation
  • Conditional formatting
  • Charts
  • Pictures
  • Shapes
  • Comments
  • Tables
  • Pivot tables
  • Protection
  • Encryption
  • VBA
  • Formula calculation
  • Many more...

Overview

This project started with the source from ExcelPackage. It was a great project to start from. It had the basic functionality needed to read and write a spreadsheet. Advantages over other: EPPlus uses dictionaries to access cell data, making performance a lot better. Complete integration with .NET

Support

All support is currently referred to Stack overflow. A tutorial is available in the wiki and the sample project can be downloaded with each version. The old site at Codeplex also contains material that can be helpful. Bugs and new feature requests can be added to the issues tracker.

License

The project is licensed under the GNU Library General Public License (LGPL).