Skip to content
Mats Alm edited this page Dec 4, 2023 · 8 revisions

Load data into a spreadsheet

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

  • LoadFromText and LoadFromTextAsync- Read a text file (csv, tsv, etc) and load the data into a range on a worksheet.
  • LoadFromDataReader and LoadFromDataReaderAsync - Loads data into a range from an System.Data.IDataReader
  • LoadFromDataTable - Loads data into a range from a System.Data.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.

See also

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally