Dexiom / Dexiom.EPPlusExporter

A very simple, yet incredibly powerfull library to generate Excel documents out of objects, arrays, lists, collections, etc.
MIT License
19 stars 16 forks source link
epplus excel fluent-interface spreadsheet xlsx

Dexiom.EPPlusExporter

Build status NuGet

Download & Install

Install-Package Dexiom.EPPlusExporter

Wiki

Please review the Wiki pages on how to use Dexiom.EPPlusExporter.

Quick Usage Preview

Basic example

Let's say you want to dump an array or a list of objects to Excel (without any specific formatting).
This is what you would do:

//create the exporter
var exporter = EnumerableExporter.Create(employees);

//generate the document
var excelPackage = exporter.CreateExcelPackage(); 

//save the document
excelPackage.SaveAs(new FileInfo("C:\\example1.xlsx")); 

Quick Customizations (using fluent interface)

Quick customization can be accomplished by using the fluent interface like this:

var excelPackage = EnumerableExporter.Create(employees)
    .DefaultNumberFormat(typeof(DateTime), "yyyy-MM-dd") //set a default format for all DateTime columns
    .NumberFormatFor(n => n.DateOfBirth, "yyyy-MMM-dd") //set a specific format for the "DateOfBirth"
    .Ignore(n => new { n.UserName, n.Email }) //remove 2 columns from the output
    .TextFormatFor(n => n.Phone, "Cell: {0}") //add a prefix to the value
    .StyleFor(n => n.DateContractEnd, style =>
    {
        style.Fill.Gradient.Color1.SetColor(Color.Yellow);
        style.Fill.Gradient.Color2.SetColor(Color.Green);
    }) //the cells in this columns now have a gradiant background
    .CreateExcelPackage();

License

Copyright (c) Consultation Dexiom. All rights reserved.

Licensed under the MIT License.