Class OdsStreamReader
- Namespace
- OdfKit.Spreadsheet
- Assembly
- OdfKit.dll
Provides the OdsStreamReader API. 以低記憶體流式方式逐列讀取 ODS 試算表,適用於大型資料集。
public sealed class OdsStreamReader : DbDataReader, IDataReader, IDisposable, IDataRecord, IEnumerable, IAsyncDisposable
- Inheritance
-
OdsStreamReader
- Implements
- Inherited Members
Constructors
OdsStreamReader(Stream)
Initializes an OdsStreamReader from a stream. 從資料流初始化 OdsStreamReader。
public OdsStreamReader(Stream stream)
Parameters
streamStreamThe ODS file stream, which must be ZIP-compatible. / ODS 檔案資料流,需為 ZIP 相容格式。
OdsStreamReader(Stream, OdsStreamReaderOptions)
Initializes an OdsStreamReader from a stream with explicit resource limits. 使用明確資源限制,從資料流初始化 OdsStreamReader。
public OdsStreamReader(Stream stream, OdsStreamReaderOptions options)
Parameters
streamStreamThe ODS file stream. / ODS 檔案資料流。
optionsOdsStreamReaderOptionsThe reader options. / 讀取器選項。
OdsStreamReader(string)
Initializes an OdsStreamReader from a path. 從路徑初始化 OdsStreamReader。
public OdsStreamReader(string path)
Parameters
pathstringThe ODS file path. / ODS 檔案路徑。
OdsStreamReader(string, OdsStreamReaderOptions)
Initializes an OdsStreamReader from a path with explicit resource limits. 使用明確資源限制,從路徑初始化 OdsStreamReader。
public OdsStreamReader(string path, OdsStreamReaderOptions options)
Parameters
pathstringThe ODS file path. / ODS 檔案路徑。
optionsOdsStreamReaderOptionsThe reader options. / 讀取器選項。
Properties
Depth
Gets the nesting depth of the current row. This implementation always returns 0. 取得目前資料列的巢狀深度。此實作恆傳回 0。
public override int Depth { get; }
Property Value
FieldCount
Gets the number of fields in the current row. 取得目前列的欄位數
public override int FieldCount { get; }
Property Value
HasRows
Gets a value indicating whether the data reader contains one or more rows. 取得一個值,指出資料讀取器是否包含一或多個資料列。
public override bool HasRows { get; }
Property Value
IsClosed
Gets a value indicating whether the data reader is closed. 取得一個值,指出資料讀取器是否已關閉。
public override bool IsClosed { get; }
Property Value
this[int]
Gets the value of the column at the specified column index. 取得指定資料行索引處之資料行的值。
public override object this[int ordinal] { get; }
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Property Value
- object
The value of the column. / 該資料行的值。
this[string]
Gets the value of the column with the specified column name. 取得指定資料行名稱處之資料行的值。
public override object this[string name] { get; }
Parameters
namestringThe column name. / 資料行的名稱。
Property Value
- object
The value of the column. / 該資料行的值。
RecordsAffected
Gets the number of rows changed, inserted, or deleted by executing the SQL statement. This implementation always returns -1. 取得執行 SQL 陳述式所變更、插入或刪除的資料列數目。此實作恆傳回 -1。
public override int RecordsAffected { get; }
Property Value
RowIndex
Gets the current zero-based row number. 取得目前列號(0-based)
public int RowIndex { get; }
Property Value
SheetNames
Gets the sheet name list scanned from the top level of content.xml.
工作表名稱清單(從 content.xml 頂層掃描取得)
public IReadOnlyList<string> SheetNames { get; }
Property Value
Methods
Dispose(bool)
Releases unmanaged resources. 釋放非受控資源。
protected override void Dispose(bool disposing)
Parameters
disposingbool
GetBoolean(int)
Gets the value of the specified column as a Boolean. 取得指定資料行之布林值形式的值。
public override bool GetBoolean(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- bool
The Boolean value of the column. / 該資料行的布林值。
GetByte(int)
Gets the value of the specified column as an 8-bit unsigned integer. 取得指定資料行之 8 位元無號整數值形式的值。
public override byte GetByte(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- byte
The byte value of the column. / 該資料行的位元組值。
GetBytes(int, long, byte[]?, int, int)
Reads a stream of bytes from the specified column and copies it into the specified buffer. 從指定的資料行讀取位元組資料流,複製到指定的緩衝區。
public override long GetBytes(int ordinal, long dataOffset, byte[]? buffer, int bufferOffset, int length)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
dataOffsetlongThe index in the column where the read operation begins. / 資料行中開始讀取作業的索引。
bufferbyte[]The buffer into which data is copied. / 要將資料複製入其中的緩衝區。
bufferOffsetintThe index in the buffer where the write operation begins. / 緩衝區中開始寫入作業的索引。
lengthintThe maximum number of bytes to copy. / 要複製的最大位元組數。
Returns
- long
The actual number of bytes copied. / 實際複製的位元組數。
GetCell(int)
Gets the structured value and source metadata for a cell in the current row. 取得目前資料列中儲存格的結構化值與來源中繼資料。
public OdsCellValue GetCell(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- OdsCellValue
The structured cell value. / 結構化儲存格值。
GetChar(int)
Gets the value of the specified column as a character. 取得指定資料行之字元形式的值。
public override char GetChar(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- char
The character value of the column. / 該資料行的字元值。
GetChars(int, long, char[]?, int, int)
Reads a stream of characters from the specified column and copies it into the specified buffer. 從指定的資料行讀取字元資料流,複製到指定的緩衝區。
public override long GetChars(int ordinal, long dataOffset, char[]? buffer, int bufferOffset, int length)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
dataOffsetlongThe index in the column where the read operation begins. / 資料行中開始讀取作業的索引。
bufferchar[]The buffer into which data is copied. / 要將資料複製入其中的緩衝區。
bufferOffsetintThe index in the buffer where the write operation begins. / 緩衝區中開始寫入作業的索引。
lengthintThe maximum number of characters to copy. / 要複製的最大字元數。
Returns
- long
The actual number of characters copied. / 實際複製的字元數。
GetDataTypeName(int)
Gets the data type name of the specified column. 取得指定資料行的資料類型名稱。
public override string GetDataTypeName(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- string
The data type name. / 資料類型的名稱。
GetDateTime(int)
Gets the value of the specified column as a DateTime. 取得指定資料行之 DateTime 形式的值。
public override DateTime GetDateTime(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
GetDecimal(int)
Gets the value of the specified column as a decimal number. 取得指定資料行之十進位數值形式的值。
public override decimal GetDecimal(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- decimal
The decimal value of the column. / 該資料行的十進位數值。
GetDouble(int)
Gets the value of the specified column as a double-precision floating-point number. 取得指定資料行之倍精確度浮點數值形式的值.
public override double GetDouble(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- double
The double-precision floating-point value of the column. / 該資料行的倍精確度浮點數值。
GetEnumerator()
Returns an enumerator that can be used to iterate through rows. 傳回可用來逐一查看資料列的列舉程式。
public override IEnumerator GetEnumerator()
Returns
- IEnumerator
An IEnumerator that can be used to iterate through results. / 一個 IEnumerator,可用於逐一查看結果。
GetFieldType(int)
Gets the Type of the data type of the specified column. 取得指定資料行之資料類型的 Type。
public override Type GetFieldType(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
GetFloat(int)
Gets the value of the specified column as a single-precision floating-point number. 取得指定資料行之單精確度浮點數值形式的值。
public override float GetFloat(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- float
The single-precision floating-point value of the column. / 該資料行的單精確度浮點數值。
GetGuid(int)
Gets the value of the specified column as a globally unique identifier (GUID). 取得指定資料行之全域唯一識別碼 (GUID) 形式的值。
public override Guid GetGuid(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- Guid
The GUID value of the column. / 該資料行的 GUID 值。
GetInt16(int)
Gets the value of the specified column as a 16-bit signed integer. 取得指定資料行之 16 位元有號整數值形式的值。
public override short GetInt16(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- short
The 16-bit signed integer value of the column. / 該資料行的 16 位元有號整數值。
GetInt32(int)
Gets the value of the specified column as a 32-bit signed integer. 取得指定資料行之 32 位元有號整數值形式的值。
public override int GetInt32(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- int
The 32-bit signed integer value of the column. / 該資料行的 32 位元有號整數值。
GetInt64(int)
Gets the value of the specified column as a 64-bit signed integer. 取得指定資料行之 64 位元有號整數值形式的值。
public override long GetInt64(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- long
The 64-bit signed integer value of the column. / 該資料行的 64 位元有號整數值。
GetName(int)
Gets the name of the specified column. 取得指定資料行的名稱。
public override string GetName(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- string
The column name. / 資料行的名稱。
GetOrdinal(string)
Gets the column index for the specified column name. 取得指定資料行名稱的資料行索引。
public override int GetOrdinal(string name)
Parameters
namestringThe column name. / 資料行的名稱。
Returns
- int
The zero-based column index, or -1 if the column is not found. / 採零起始的資料行索引;若找不到則為 -1。
GetSchemaTable()
Returns a DataTable that describes the DbDataReader metadata. This implementation always returns null. 傳回說明 DbDataReader 之中繼資料的 DataTable。此實作恆傳回 null。
public override DataTable? GetSchemaTable()
Returns
- DataTable
A DataTable that describes this reader's schema metadata, or null. / 一個 DataTable,描述此讀取器的結構描述中繼資料;或是 null。
GetString(int)
Gets the value of the specified column as a string. 取得指定資料行之字串形式的值。
public override string GetString(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
- string
The string value of the column. / 該資料行的字串值。
GetValue(int)
Gets the raw value of the specified column in the current row. Float values become double, Boolean values become bool, date values become DateTime, and other values become strings. 取得目前列指定欄的原始值(float→double、boolean→bool、date→DateTime、其餘→string)
public override object GetValue(int ordinal)
Parameters
ordinalintThe zero-based field index. / 採 0 為基準的欄位索引。
Returns
GetValues(object[])
Copies the values of all columns in the current row into the specified array. 將目前資料列中所有資料行的值複製到指定的陣列中。
public override int GetValues(object[] values)
Parameters
Returns
- int
The number of array items populated with values. / 陣列中被填入值的項目個數。
IsDBNull(int)
Gets a value indicating whether the specified column contains a null or missing value. 取得一個值,指出指定資料行是否包含 Null 或不存在的值。
public override bool IsDBNull(int ordinal)
Parameters
ordinalintThe zero-based column index. / 採零起始的資料行索引。
Returns
NextResult()
Advances the data reader to the next result. This implementation always returns false. 使資料讀取器前進至下一個結果。此實作恆傳回 false。
public override bool NextResult()
Returns
Read()
Reads the next row; returns false when the worksheet has ended. 讀取下一列;回傳 false 代表工作表結束
public override bool Read()
Returns
ReadAsync(CancellationToken)
Asynchronously reads the next row and observes cancellation during package XML I/O. 非同步讀取下一列,並在封裝 XML I/O 期間回應取消要求。
public override Task<bool> ReadAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token. / 取消權杖。
Returns
SelectSheet(int)
Switches to the worksheet with the specified index. This must be called before the first Read(). 切換至指定索引的工作表(必須在第一次 Read() 前呼叫)
public void SelectSheet(int sheetIndex)
Parameters
sheetIndexintThe zero-based worksheet index. / 採 0 為基準的工作表索引。