Method FillDataTable
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
FillDataTable(DataTable, XlsxCellRange?, XlsxExportOptions?)
Reads a range into a table of your own: each cell is given as the type of the column it goes to, so the table's schema is the one you defined.
public int FillDataTable(DataTable table, XlsxCellRange? range = null, XlsxExportOptions? options = null)
Parameters
tableDataTableThe table to add rows to. Its columns are not changed.
rangeXlsxCellRange?The range, or null for every cell the sheet stores.
optionsXlsxExportOptionsThe options, or null for the defaults.
Returns
- int
The number of rows added.
Remarks
With FirstRowIsHeader, a column of the range goes to the table column whose name is its heading, compared without regard to case; a heading the table has no column for is skipped, and a table column no heading names is left to its default. Without it, columns go by position. A cell that cannot be given as the column's type (text in a number column, a number too large, an error value) is DBNull and is reported in Issues; a row the table refuses (a null in a column that allows none, a broken constraint) is left out and reported.
Exceptions
- ArgumentNullException
tableis null.- ResourceLimitExceededException
The range covers more cells than MaxCells.
- InvalidDocumentException
The sheet's part is malformed; or Strict is set and a cell or a row could not be given.