Class OdtStreamReader
Reads an ODT text document paragraph by paragraph in a low-memory streaming fashion, suitable for text extraction from large documents. 以低記憶體流式方式逐段落讀取 ODT 文字文件,適用於大型文件文字擷取。
public sealed class OdtStreamReader : IDisposable
- Inheritance
-
OdtStreamReader
- Implements
- Inherited Members
Constructors
OdtStreamReader(Stream)
Initializes a new instance of the OdtStreamReader class from a stream. 從資料流初始化 OdtStreamReader 類別的新執行個體。
public OdtStreamReader(Stream stream)
Parameters
streamStreamThe ODT file stream. / ODT 檔案資料流。
Exceptions
- ArgumentNullException
Thrown when
streamis null. / 當stream為 null 時擲出。
OdtStreamReader(Stream, OdtStreamReaderOptions)
Initializes a reader from a stream with explicit resource limits. 使用明確資源限制,從資料流初始化讀取器。
public OdtStreamReader(Stream stream, OdtStreamReaderOptions options)
Parameters
streamStreamThe ODT file stream. / ODT 檔案資料流。
optionsOdtStreamReaderOptionsThe reader options. / 讀取器選項。
OdtStreamReader(string)
Initializes a new instance of the OdtStreamReader class from a file path. 從檔案路徑初始化 OdtStreamReader 類別的新執行個體。
public OdtStreamReader(string path)
Parameters
pathstringThe ODT file path. / ODT 檔案路徑。
Exceptions
- ArgumentNullException
Thrown when
pathis null. / 當path為 null 時擲出。
OdtStreamReader(string, OdtStreamReaderOptions)
Initializes a reader from a path with explicit resource limits. 使用明確資源限制,從路徑初始化讀取器。
public OdtStreamReader(string path, OdtStreamReaderOptions options)
Parameters
pathstringThe ODT file path. / ODT 檔案路徑。
optionsOdtStreamReaderOptionsThe reader options. / 讀取器選項。
Properties
HeadingLevel
public int HeadingLevel { get; }
Property Value
NodeType
Gets the type of the current element. 取得目前元素的類型。
public OdtNodeType NodeType { get; }
Property Value
StyleName
Gets the paragraph style name of the current element. 取得目前元素的段落樣式名稱。
public string? StyleName { get; }
Property Value
Text
Gets the plain text content of the current element, including embedded text:span text.
取得目前元素的純文字內容,包含內嵌 text:span 文字。
public string Text { get; }
Property Value
Methods
Dispose()
Releases the reader and underlying ZIP resources. 釋放讀取器與底層 ZIP 資源。
public void Dispose()
Read()
Reads the next text element; returns false to indicate the end of the document. 讀取下一個文字元素;回傳 false 代表文件結束。
public bool Read()
Returns
ReadAsync(CancellationToken)
Asynchronously reads the next text element and observes cancellation during XML traversal. 非同步讀取下一個文字元素,並在 XML 走訪期間回應取消要求。
public Task<bool> ReadAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token. / 取消權杖。