Table of Contents

Class OdtStreamWriter

Namespace
OdfKit.Text
Assembly
OdfKit.dll

Writes ODT text documents paragraph by paragraph with a forward-only streaming API. 提供以資料流方式逐段落寫入 ODT 文字文件的功能,適用於大型文件生成。

public sealed class OdtStreamWriter : IDisposable, IAsyncDisposable
Inheritance
OdtStreamWriter
Implements
Inherited Members

Constructors

OdtStreamWriter(Stream)

Initializes a new instance of the OdtStreamWriter class. 初始化 OdtStreamWriter 類別的新執行個體。

public OdtStreamWriter(Stream outputStream)

Parameters

outputStream Stream

Exceptions

ArgumentNullException

Thrown when outputStream is null. / 當 outputStream 為 null 時擲出。

OdtStreamWriter(Stream, OdfVersion)

Short overload of OdtStreamWriter that accepts outputStream and version; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 outputStream 與 version;其餘可選參數使用預設值並轉呼叫最長 OdtStreamWriter 多載。

public OdtStreamWriter(Stream outputStream, OdfVersion version)

Parameters

outputStream Stream
version OdfVersion

OdtStreamWriter(string)

Initializes a new instance of the OdtStreamWriter class from a file path. 從檔案路徑初始化 OdtStreamWriter 類別的新執行個體。

public OdtStreamWriter(string path)

Parameters

path string

Exceptions

ArgumentNullException

Thrown when path is null. / 當 path 為 null 時擲出。

OdtStreamWriter(string, OdfVersion)

Short overload of OdtStreamWriter that accepts path and version; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 version;其餘可選參數使用預設值並轉呼叫最長 OdtStreamWriter 多載。

public OdtStreamWriter(string path, OdfVersion version)

Parameters

path string
version OdfVersion

Methods

AddHeading(ReadOnlyMemory<char>)

Adds a heading paragraph. 加入標題段落。

public void AddHeading(ReadOnlyMemory<char> text)

Parameters

text ReadOnlyMemory<char>

The heading text. / 標題文字。

Exceptions

ArgumentOutOfRangeException

Thrown when is not between 1 and 6. / 當 不在 1 到 6 之間時擲出。

AddHeading(ReadOnlyMemory<char>, int)

Short overload of AddHeading that accepts text and level; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 text 與 level;其餘可選參數使用預設值並轉呼叫最長 AddHeading 多載。

public void AddHeading(ReadOnlyMemory<char> text, int level)

Parameters

text ReadOnlyMemory<char>
level int

AddHeading(ReadOnlySpan<char>)

Adds a heading paragraph. 加入標題段落。

public void AddHeading(ReadOnlySpan<char> text)

Parameters

text ReadOnlySpan<char>

The heading text. / 標題文字。

Exceptions

ArgumentOutOfRangeException

Thrown when is not between 1 and 6. / 當 不在 1 到 6 之間時擲出。

AddHeading(ReadOnlySpan<char>, int)

Full overload of AddHeading that accepts text and level. AddHeading 完整多載:接受 text 與 level。

public void AddHeading(ReadOnlySpan<char> text, int level)

Parameters

text ReadOnlySpan<char>
level int

AddHeading(string)

Adds a heading paragraph. 加入標題段落。

public void AddHeading(string text)

Parameters

text string

The heading text. / 標題文字。

Exceptions

ArgumentOutOfRangeException

Thrown when is not between 1 and 6. / 當 不在 1 到 6 之間時擲出。

AddHeading(string, int)

Full overload of AddHeading that accepts text and level. AddHeading 完整多載:接受 text 與 level。

public void AddHeading(string text, int level)

Parameters

text string
level int

AddListItem(ReadOnlyMemory<char>)

Adds a list item. 加入清單專案。

public void AddListItem(ReadOnlyMemory<char> text)

Parameters

text ReadOnlyMemory<char>

The list item text. / 清單專案文字。

Exceptions

InvalidOperationException

Thrown when BeginList(string?) has not been called. / 當尚未呼叫 BeginList(string?) 時擲出。

AddListItem(ReadOnlySpan<char>)

Adds a list item. 加入清單專案。

public void AddListItem(ReadOnlySpan<char> text)

Parameters

text ReadOnlySpan<char>

The list item text. / 清單專案文字。

Exceptions

InvalidOperationException

Thrown when BeginList(string?) has not been called. / 當尚未呼叫 BeginList(string?) 時擲出。

AddListItem(string)

Adds a list item. 加入清單專案。

public void AddListItem(string text)

Parameters

text string

The list item text. / 清單專案文字。

Exceptions

InvalidOperationException

Thrown when BeginList(string?) has not been called. / 當尚未呼叫 BeginList(string?) 時擲出。

AddPageBreak()

Adds a forced page break. 加入強制分頁。

public void AddPageBreak()

AddParagraph(ReadOnlyMemory<char>)

Adds a paragraph from a prebound writer callback. 加入一個段落。

public void AddParagraph(ReadOnlyMemory<char> text)

Parameters

text ReadOnlyMemory<char>

AddParagraph(ReadOnlyMemory<char>, string?)

Short overload of AddParagraph that accepts text and styleName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 text 與 styleName;其餘可選參數使用預設值並轉呼叫最長 AddParagraph 多載。

public void AddParagraph(ReadOnlyMemory<char> text, string? styleName)

Parameters

text ReadOnlyMemory<char>
styleName string

AddParagraph(ReadOnlySpan<char>)

Adds a paragraph with the specified rich text runs. 加入一個段落。

public void AddParagraph(ReadOnlySpan<char> text)

Parameters

text ReadOnlySpan<char>

AddParagraph(ReadOnlySpan<char>, string?)

Full overload of AddParagraph that accepts text and styleName. AddParagraph 完整多載:接受 text 與 styleName。

public void AddParagraph(ReadOnlySpan<char> text, string? styleName)

Parameters

text ReadOnlySpan<char>
styleName string

AddParagraph(string)

Adds a paragraph with the specified text content. 加入一個段落。

public void AddParagraph(string text)

Parameters

text string

AddParagraph(string, string?)

Full overload of AddParagraph that accepts text and styleName. AddParagraph 完整多載:接受 text 與 styleName。

public void AddParagraph(string text, string? styleName)

Parameters

text string
styleName string

BeginList()

Short overload of BeginList that uses default values for all optional parameters and forwards to the full overload. 便利多載:BeginList 的所有可選參數使用預設值並轉呼叫最長多載。

public void BeginList()

BeginList(string?)

Begins a list. 開始清單。

public void BeginList(string? styleName)

Parameters

styleName string

The list style name. / 清單樣式名稱。

Exceptions

InvalidOperationException

Thrown when a list has already begun. / 當清單已經開始時擲出。

CompleteAsync(CancellationToken)

Asynchronously flushes document content and completes the ODT package while observing cancellation before ZIP finalization. 非同步沖洗文件內容並完成 ODT 封裝,且在 ZIP 最終化前回應取消要求。

public Task CompleteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

Task

A task representing package completion. / 代表封裝完成作業的工作。

Remarks

The final ZIP central-directory commit is synchronous because ZipArchive exposes only synchronous disposal. 最後的 ZIP 中央目錄提交為同步作業,因為 ZipArchive 僅提供同步處置。

Dispose()

Releases resources and finalizes the document ZIP structure. 釋放資源並最終化文件 ZIP 結構。

public void Dispose()

DisposeAsync()

Asynchronously releases resources and finalizes the document ZIP structure. 非同步釋放資源並最終化文件 ZIP 結構。

public ValueTask DisposeAsync()

Returns

ValueTask

A ValueTask representing the asynchronous dispose operation. / 代表非同步處置作業的 ValueTask

EndList()

Ends the current list. 結束目前清單。

public void EndList()

WriteNode(OdfNode)

Writes an existing DOM subtree directly at the current position in the text document. 將既有 DOM 子樹直接寫入目前文字文件位置。

public void WriteNode(OdfNode node)

Parameters

node OdfNode

The DOM node to write. / 要寫入的 DOM 節點。

Exceptions

ArgumentNullException

Thrown when node is null. / 當 node 為 null 時擲出。

ArgumentException

Thrown when the subtree contains text or attribute values with characters that are not valid in XML 1.0. / 當子樹的文字或屬性值含有 XML 1.0 不允許的字元時擲出。