Import - DON-PHAM/EPPlus GitHub Wiki

Load data into a spreadsheet

From the Cells property (ExcelRange) you can access these methods to load data from various sources:

  • LoadFromText and LoadFromTextAsync- Read a csv text file and load the data into a range on a worksheet.
  • LoadFromDataReader and LoadFromDataReaderAsync - Loads data into a range from a DataReader
  • LoadFromDataTable - Loads data into a range from a DataTable. Can be used for importing data from a range of sources, like XML (example provided) and databases.
  • LoadFromCollection - Loads data into a range from an IEnumerable using reflection.
  • LoadFromCollection using attributes - Loads data into a range/table from an IEnumerable using reflection. Uses attributes that specifies styling, number formats, formulas, etc.
  • LoadFromDictionaries - Loads data into a range from an IEnumerable of ExpandoObject/dynamic objects (via their IDictionary<string, object> interface. Useful for importing json data, example provided.
  • LoadFromArrays - Loads data into a range from an IEnumerable of object[] where each object array becomes a row in the worksheet.

You can optionally specify a parameter to create an ExcelTable when you use these methods. For more detailed examples, have a look at sample 4 & 5 the sample project Sample-.NET Framework or Sample-.NET Framework.