.NET API for Excel Spreadsheets Manipulation 

Read, Write, Edit & Export Excel Spreadsheet Files, Add Images & Comments to Cells in XLSX via Open Source Free C# .NET Excel Library.

What is EPPlus?

EPPlus is a pure .NET library that gives software developers the capability to read, write & export Excel 2007/2010 files in OOXML format.

The project started with the source from ExcelPackage, which had basic functionality to read and write spreadsheets. EPPlus’s performance is much enhanced because it uses dictionaries to access spreadsheet cell data. The API provides cell access via ranges, cell merging, the addition of pictures, shapes & charts, hyperlinks & header/footer management, freeze panes, Pivot Table, data validation, worksheets & workbook protection, encryption or decryption, and more.

Previous Next

Getting Started with EPPlus

You need to have .NET Framework 3.5 or above. Once you have met the prerequisites, you can manually download the repository from GitHub or install from NuGet.

Install EPPlus from NuGet

 Install-Package EPPlus

Create & Modify Spreadsheet Files via .NET

EPPlus allows .NET programmers to create as well as modify Excel spreadsheets from their own .NET applications. Once the worksheet is created you can assign a name to it and can set the default font for all cells.

How to Create a New Excel XLSX file via C# API?

// Create a new Excel file
ExcelPackage excelPackage = new ExcelPackage();
// Add work sheet 
ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets.Add("FileFormat");
// Add data in cell
excelWorksheet.Cells["A1"].Value = "File Format Developer Guide";
// Save as XLSX file format
excelPackage.SaveAs(new FileInfo("fileformat.xlsx"));

Add Image to Excel Sheet with C#

.NET programmers can add Images into an Excel Sheet using EPPlus open source C# library. You can define the picture width & height and the position where you want to place it. Developers can also modify the picture position and place it where they want it. Resizing columns and rows after using the available method will affect the size of the picture.

How to Add Image in Excel via C# .NET?

// Create a new Excel file
ExcelPackage excelPackage = new ExcelPackage();
// Add work sheet 
ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets.Add("FileFormat");
// Add picture
ExcelPicture excelPicture = excelWorksheet.Drawings.AddPicture("logo", Image.FromFile("logo.png"));
// Set position
excelPicture.SetPosition(3, 0, 3, 0);
// Save as XLSX file format
excelPackage.SaveAs(new FileInfo("fileformat.xlsx"));

Add Comments to Excel Cell

EPPlus API facilitates adding and modifying comments in Excel cells. The API also supports features like adding a comment, moving the comment box, displaying or hiding comments, deleting a comment, comment formatting, etc.

How to Add Comments in Excel Cell via C# API?

// Create a new Excel file
ExcelPackage excelPackage = new ExcelPackage();
// Add work sheet 
ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets.Add("FileFormat");
// Add comment
ExcelComment excelComment = excelWorksheet.Cells["A1"].AddComment("FileFormat.com", "Ali Ahmed");
// Set font to bold
excelComment.Font.Bold = true;
// Set font to Italic
excelComment.Font.Italic = true;
// Add comment text 
ExcelRichText excelRichText = excelComment.RichText.Add("File Format Developer Guide");
// Save as XLSX file format
excelPackage.SaveAs(new FileInfo("fileformat.xlsx"));
 English