-
Notifications
You must be signed in to change notification settings - Fork 303
LoadFromDataTable
Mats Alm edited this page Jul 21, 2020
·
19 revisions
This method loads a System.Data.DataTable into a spreadshet.
A DataTable can be filled with data from various sources, often a database. In this simple example we will create it and fill it ourselves.
var table = new DataTable("Astronauts");
table.Columns.Add("Id", typeof(int));
table.Columns.Add("FirstName", typeof(string));
table.Columns.Add("LastName", typeof(string));
// add some data
table.Rows.Add(1, "Bob", "Behnken");
table.Rows.Add(2, "Doug", "Hurley");
//create a workbook with a spreadsheet and load the data table
using(var package = new ExcelPackage())
{
var sheet = package.Workbook.Worksheets.Add("Astronauts");
sheet.Cells["A1"].LoadFromDataTable(table);
}EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles
-
Formula Calculation
- Security considerations
- Circular references
- Referencing tables in formulas
- Supported Functions
- Dynamic array formulas
- Legacy array formulas
- Lambda functions
- Regression analysis functions
- Custom functions for calculations
- Function prefixes
- Precision as Displayed
- Cancelling a calculation
- Trim reference operator
- Working with filters
- Working with slicers
- Working with External Workbooks