ExcelWorkbookDataReader
OfficeIMO.Excel
Package-owned ADO.NET projection for XLSX, XLSM, XLTX, XLTM, XLAM, XLSB, and BIFF8 XLS workbook worksheets.
Inheritance
- DbDataReader
- ExcelWorkbookDataReader
Usage
Explore 4 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 4
- Method ExcelDocument.CreateDataReader
- Method ExcelDocument.OpenReader
- Method ExcelDocument.OpenReaderAsync
- Method ExcelSheet.CreateDataReader
Methods
public override bool GetBoolean(int ordinal) #When overridden in a derived class, gets the value of the specified column as a Boolean.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
bool The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override byte GetByte(int ordinal) #When overridden in a derived class, gets the value of the specified column as a byte.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
byte The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length) #When overridden in a derived class, reads a specified number of bytes from the specified column starting at a specified index and writes them to a buffer starting at a specified position in the buffer.
Parameters
- ordinal int
- The zero-based column ordinal.
- dataOffset long
- The index within the row from which to begin the read operation.
- buffer byte[]?
- The buffer into which to copy the data.
- bufferOffset int
- The index with the buffer to which the data will be copied.
- length int
- The maximum number of bytes to read.
Returns
long The actual number of bytes read.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override char GetChar(int ordinal) #When overridden in a derived class, gets the value of the specified column as a single character.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
char The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length) #When overridden in a derived class, reads a specified number of characters from a specified column starting at a specified index, and writes them to a buffer starting at a specified position.
Parameters
- ordinal int
- The zero-based column ordinal.
- dataOffset long
- The index within the row from which to begin the read operation.
- buffer char[]?
- The buffer into which to copy the data.
- bufferOffset int
- The index with the buffer to which the data will be copied.
- length int
- The maximum number of characters to read.
Returns
long The actual number of characters read.public override string GetDataTypeName(int ordinal) #When overridden in a derived class, gets name of the data type of the specified column.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
string The name of the data type.Exceptions
IndexOutOfRangeException– The column index is out of range.
public override DateTime GetDateTime(int ordinal) #When overridden in a derived class, gets the value of the specified column as a DateTime object.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
DateTime The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override decimal GetDecimal(int ordinal) #When overridden in a derived class, gets the value of the specified column as a decimal.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
decimal The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override double GetDouble(int ordinal) #When overridden in a derived class, gets the value of the specified column as a double-precision floating point number.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
double The value of the specified column.Exceptions
InvalidCastException– The specified cast is not valid.
public override IEnumerator GetEnumerator() #When overridden in a derived class, returns an enumerator that can be used to iterate through the rows in the data reader.
Returns
IEnumerator An enumerator that can be used to iterate through the rows in the data reader.public override Type GetFieldType(int ordinal) #When overridden in a derived class, gets the data type of the specified column.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
Type The data type of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override T? GetFieldValue<T>(int ordinal) #Gets the value of the specified column as the requested type.
Type Parameters
- T
- The type of the value to be returned.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
T? The value of the specified column.Exceptions
InvalidOperationException– The connection was dropped or closed during data retrieval. -or- The data reader was closed during data retrieval. -or- There is no data ready to be read (for example, the first DbDataReader.Read hasn't been called, or it returned false). -or- The reader tried to read a previously-read column in sequential mode. -or- There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.IndexOutOfRangeException– The column index is out of range.InvalidCastException– The value returned by the database doesn't match or cannot be cast to T.
public override float GetFloat(int ordinal) #When overridden in a derived class, gets the value of the specified column as a single-precision floating point number.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
float The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override Guid GetGuid(int ordinal) #When overridden in a derived class, gets the value of the specified column as a globally unique identifier (GUID).
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
Guid The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override short GetInt16(int ordinal) #When overridden in a derived class, gets the value of the specified column as a 16-bit signed integer.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
short The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override int GetInt32(int ordinal) #When overridden in a derived class, gets the value of the specified column as a 32-bit signed integer.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
int The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override long GetInt64(int ordinal) #When overridden in a derived class, gets the value of the specified column as a 64-bit signed integer.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
long The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override string GetName(int ordinal) #When overridden in a derived class, gets the name of the column, given the zero-based column ordinal.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
string The name of the specified column.public override int GetOrdinal(string name) #When overridden in a derived class, gets the column ordinal given the name of the column.
Parameters
- name string
- The name of the column.
Returns
int The zero-based column ordinal.Exceptions
IndexOutOfRangeException– The name specified is not a valid column name.
public override DataTable? GetSchemaTable() #Returns a DataTable that describes the column metadata of the DbDataReader. Returns null if the executed command returned no resultset, or after DbDataReader.NextResult returns false.
Returns
DataTable? A DataTable that describes the column metadata.Exceptions
InvalidOperationException– The DbDataReader is closed.IndexOutOfRangeException– The column index is out of range.NotSupportedException– .NET Core and .NET 5+ only: In all cases.
public override string GetString(int ordinal) #When overridden in a derived class, gets the value of the specified column as an instance of string.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
string The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.InvalidCastException– The specified cast is not valid.
public override object GetValue(int ordinal) #When overridden in a derived class, gets the value of the specified column as an instance of object.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
object The value of the specified column.Exceptions
IndexOutOfRangeException– The column index is out of range.
public override int GetValues(object[] values) #When overridden in a derived class, populates an array of objects with the column values of the current row.
Parameters
- values object[]
- An array of object into which to copy the attribute columns.
Returns
int The number of instances of object in the array.public override bool IsDBNull(int ordinal) #When overridden in a derived class, gets a value that indicates whether the column contains nonexistent or missing values.
Parameters
- ordinal int
- The zero-based column ordinal.
Returns
bool true if the specified column is equivalent to DBNull; otherwise, false.Exceptions
IndexOutOfRangeException– The column index is out of range.
public override bool NextResult() #When overridden in a derived class, advances the reader to the next result when reading the results of a batch of statements.
Returns
bool true if there are more result sets; otherwise, false.public override Task<bool> NextResultAsync(CancellationToken cancellationToken) #Asynchronously advances the reader to the next result when reading the results of a batch of statements.
Parameters
- cancellationToken System.Threading.CancellationToken
- The cancellation instruction.
Returns
Task<bool> A Task<T> whose Task<T>.Result property is true if there are more result sets or false if there aren't.Exceptions
DbException– An error occurred while executing the command text.
public override bool Read() #When overridden in a derived class, advances the reader to the next record in a result set.
Returns
bool true if there are more rows; otherwise, false.public override async Task<bool> ReadAsync(CancellationToken cancellationToken) #Asynchronously advances the reader to the next record in a result set.
Parameters
- cancellationToken System.Threading.CancellationToken
- The cancellation instruction.
Returns
Task<bool> A Task<T> whose Task<T>.Result property is true if there are more rows or false if there aren't.Exceptions
DbException– An error occurred while executing the command text.
public bool TryGetUtf8Text(int ordinal, out ReadOnlySpan<byte> text) #Attempts to borrow the current field's text from reader-owned UTF-8 storage.
Parameters
- ordinal int
- The zero-based field ordinal.
- text System.ReadOnlySpan<byte>
- The borrowed UTF-8 text on success; otherwise an empty span.
Returns
bool True when the field is text that can be borrowed from reader-owned storage.Exceptions
IndexOutOfRangeException– The ordinal is outside the reader's fields.InvalidOperationException– The reader is closed or is not positioned on a row.
Inherited Methods
public virtual Task<ReadOnlyCollection<DbColumn>> GetColumnSchemaAsync(CancellationToken cancellationToken = default) #Parameters
- cancellationToken CancellationToken = default
Returns
Task<ReadOnlyCollection<DbColumn>>public DbDataReader GetData(int ordinal) #EditorBrowsable(1)Parameters
- ordinal int
Returns
DbDataReaderpublic Task<T?> GetFieldValueAsync<T>(int ordinal) #Type Parameters
- T
Parameters
- ordinal int
Returns
Task<T?>public virtual Task<T?> GetFieldValueAsync<T>(int ordinal, CancellationToken cancellationToken) #Type Parameters
- T
Parameters
- ordinal int
- cancellationToken CancellationToken
Returns
Task<T?>public object GetLifetimeService() #Obsolete("This Remoting API is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0010", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")Returns
objectpublic virtual Type GetProviderSpecificFieldType(int ordinal) #EditorBrowsable(1)Parameters
- ordinal int
Returns
Typepublic virtual object GetProviderSpecificValue(int ordinal) #EditorBrowsable(1)Parameters
- ordinal int
Returns
objectpublic virtual int GetProviderSpecificValues(object[] values) #EditorBrowsable(1)Parameters
- values object[]
Returns
intpublic virtual Task<DataTable?> GetSchemaTableAsync(CancellationToken cancellationToken = default) #Parameters
- cancellationToken CancellationToken = default
Returns
Task<DataTable?>public virtual Stream GetStream(int ordinal) #Parameters
- ordinal int
Returns
Streampublic virtual TextReader GetTextReader(int ordinal) #Parameters
- ordinal int
Returns
TextReaderpublic virtual object InitializeLifetimeService() #Obsolete("This Remoting API is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0010", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")Returns
objectpublic Task<bool> IsDBNullAsync(int ordinal) #Parameters
- ordinal int
Returns
Task<bool>public virtual Task<bool> IsDBNullAsync(int ordinal, CancellationToken cancellationToken) #Parameters
- ordinal int
- cancellationToken CancellationToken
Returns
Task<bool>Properties
public IReadOnlyList<string> SheetNames { get; } #Gets worksheet names exposed by this reader in workbook order.
public int CurrentSheetIndex { get; } #Gets the zero-based workbook index of the current worksheet.
public int CurrentResultIndex { get; } #Gets the zero-based index of the current reader result within ExcelWorkbookDataReader.SheetNames.
public string CurrentSheetName { get; } #Gets the worksheet name for the current result.
public override object this[int ordinal] { get; } #When overridden in a derived class, gets the value of the specified column as an instance of object.
Parameters
- ordinal int
- The zero-based column ordinal.
Exceptions
IndexOutOfRangeException– The column index is out of range.
public override object this[string name] { get; } #When overridden in a derived class, gets the value of the specified column as an instance of object.
Parameters
- name string
- The name of the column.
Exceptions
IndexOutOfRangeException– No column with the specified name was found.
public override int Depth { get; } #Gets a value indicating the depth of nesting for the current row.
public override int FieldCount { get; } #When overridden in a derived class, gets the number of columns in the current row.
Exceptions
NotSupportedException– There is no current connection to an instance of SQL Server.
public override bool HasRows { get; } #When overridden in a derived class, gets a value that indicates whether this DbDataReader contains one or more rows.
public override bool IsClosed { get; } #When overridden in a derived class, gets a value indicating whether the DbDataReader is closed.
Exceptions
InvalidOperationException– The DbDataReader is closed.
public override int RecordsAffected { get; } #When overridden in a derived class, gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
public override int VisibleFieldCount { get; } #Gets the number of fields in the DbDataReader that are not hidden.