Import data¶
Load data into a spreadsheet¶
From the Cells property (ExcelRange) you can access these methods to loads data from various sources:
LoadFromTextandLoadFromTextAsync- Read a text file (csv, tsv, etc) and load the data into a range on a worksheet.LoadFromDataReaderandLoadFromDataReaderAsync- Loads data into a range from anSystem.Data.IDataReaderLoadFromDataTable- Loads data into a range from aSystem.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 anIEnumerableusing reflection.LoadFromCollection using attributes- Loads data into a range/table from anIEnumerableusing reflection. Uses attributes that specifies styling, number formats, formulas, etc.LoadFromDictionaries- Loads data into a range from anIEnumerableofExpandoObject/dynamic objects (via theirIDictionary<string, object>interface. Useful for importing json data, example provided.LoadFromArrays- Loads data into a range from anIEnumerableofobject[]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.