Method ExportDataTable
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
ExportDataTable(XlsxCellRange?, XlsxExportOptions?)
Reads a range into a new table: one column for each column of the range, typed by what the column holds, and one row for each row.
public DataTable ExportDataTable(XlsxCellRange? range = null, XlsxExportOptions? options = null)
Parameters
rangeXlsxCellRange?The range, or null for every cell the sheet stores (Dimension).
optionsXlsxExportOptionsThe options, or null for the defaults: the first row holds the headings.
Returns
- DataTable
The table; one with no columns when the sheet stores nothing.
Remarks
A column whose cells are all numbers is decimal (double when a number is past a decimal's range); all dates, DateTime; all booleans, bool; all text, string; a column of mixed kinds is object with each value in its own type; an empty column is string. An empty cell is DBNull. A cell is a date when its number format shows it as one. A formula cell gives the result the file stores: nothing is calculated. To read into types of your choosing, fill a table of your own with FillDataTable(DataTable, XlsxCellRange?, XlsxExportOptions?).
A heading that is empty becomes Column and its position; a heading that
repeats gets _2, _3, ….
Exceptions
- ResourceLimitExceededException
The range covers more cells than MaxCells.
- InvalidDocumentException
The sheet's part is malformed; or Strict is set and a cell holds an error value.