项目作者: Dexiom

项目描述 :
A very simple, yet incredibly powerfull library to generate Excel documents out of objects, arrays, lists, collections, etc.
高级语言: C#
项目地址: git://github.com/Dexiom/Dexiom.EPPlusExporter.git
创建时间: 2017-01-16T23:00:15Z
项目社区:https://github.com/Dexiom/Dexiom.EPPlusExporter

开源协议:MIT License

下载


Dexiom.EPPlusExporter

Build status
NuGet

Download & Install

  1. 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:

  1. //create the exporter
  2. var exporter = EnumerableExporter.Create(employees);
  3. //generate the document
  4. var excelPackage = exporter.CreateExcelPackage();
  5. //save the document
  6. excelPackage.SaveAs(new FileInfo("C:\\example1.xlsx"));

Quick Customizations (using fluent interface)

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

  1. var excelPackage = EnumerableExporter.Create(employees)
  2. .DefaultNumberFormat(typeof(DateTime), "yyyy-MM-dd") //set a default format for all DateTime columns
  3. .NumberFormatFor(n => n.DateOfBirth, "yyyy-MMM-dd") //set a specific format for the "DateOfBirth"
  4. .Ignore(n => new { n.UserName, n.Email }) //remove 2 columns from the output
  5. .TextFormatFor(n => n.Phone, "Cell: {0}") //add a prefix to the value
  6. .StyleFor(n => n.DateContractEnd, style =>
  7. {
  8. style.Fill.Gradient.Color1.SetColor(Color.Yellow);
  9. style.Fill.Gradient.Color2.SetColor(Color.Green);
  10. }) //the cells in this columns now have a gradiant background
  11. .CreateExcelPackage();
  • Available customizations:
    • Ignore is used to skip a column when generating the document
    • DefaultNumberFormat is used to specify a default display format for a specific type
    • NumberFormatFor is used to set a specific format (just like you would using Excel)
    • TextFormatFor is used to convert a value to text
    • StyleFor is used to alter the style for a specific column

License

Copyright (c) Consultation Dexiom. All rights reserved.

Licensed under the MIT License.