What is EPPlus?
- A library to manage Excel spreadsheets. EPPlus is a .NET library, which reads and writes Excel 2007/2010 or higher files, using Open Office XML format. It supports .XLSX, .XLSM Excel file format.
- First of all EPPlus is a free tool.
- We can do the same thing by using Microsoft interop Excel. When you like to do Server side office automation, which is not a supported scenario by Microsoft, follow the link :http://support.microsoft.com/kb/257757
How to attach EPPlus Library
- Option 1- Download it from : http://epplus.codeplex.com/
- Option 2- To install EPPlus, run the command given below in Package Manager Console.
PM> : Install-Package EPPlus.
EPPlus supports folllowing
- Cell Ranges
- Cell styling (Border, Color, Fill, Font, Number, Alignments)
- Charts
- Pictures
- Shapes
- Comments
- Tables
- Protection
- Encryption
- Pivot tables
- Data validation
- Conditional formatting
- VBA
- Formula calculation..etc
We will learn
- Create a demo of an EPPlus project, using .NET technologies (Language C#).
Open Visual Studio (create a console Application).
- using OfficeOpenXml;
- using System.IO;
- using System;
-
- class Program {
- static void Main(string[] args) {
- ExcelPackage ExcelPkg = new ExcelPackage();
- ExcelWorksheet wsSheet1 = ExcelPkg.Workbook.Worksheets.Add("Sheet1");
- using(ExcelRange Rng = wsSheet1.Cells[2, 2, 2, 2]) {
- Rng.Value = "Welcome to Everyday be coding - tutorials for beginners";
- Rng.Style.Font.Size = 16;
- Rng.Style.Font.Bold = true;
- Rng.Style.Font.Italic = true;
- }
- wsSheet1.Protection.IsProtected = false;
- wsSheet1.Protection.AllowSelectLockedCells = false;
- ExcelPkg.SaveAs(new FileInfo(@ "D:\New.xlsx"));
- }
- }
Now, build & execute the given code. File is (New.xlsx), which is stored on D: drive of the computer.
Thank you for reading this blog.