Class OdtStreamWriter
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
outputStreamStream
Exceptions
- ArgumentNullException
Thrown when
outputStreamis 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
outputStreamStreamversionOdfVersion
OdtStreamWriter(string)
Initializes a new instance of the OdtStreamWriter class from a file path. 從檔案路徑初始化 OdtStreamWriter 類別的新執行個體。
public OdtStreamWriter(string path)
Parameters
pathstring
Exceptions
- ArgumentNullException
Thrown when
pathis 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
pathstringversionOdfVersion
Methods
AddHeading(ReadOnlyMemory<char>)
Adds a heading paragraph. 加入標題段落。
public void AddHeading(ReadOnlyMemory<char> text)
Parameters
textReadOnlyMemory<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
textReadOnlyMemory<char>levelint
AddHeading(ReadOnlySpan<char>)
Adds a heading paragraph. 加入標題段落。
public void AddHeading(ReadOnlySpan<char> text)
Parameters
textReadOnlySpan<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
textReadOnlySpan<char>levelint
AddHeading(string)
Adds a heading paragraph. 加入標題段落。
public void AddHeading(string text)
Parameters
textstringThe 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
AddListItem(ReadOnlyMemory<char>)
Adds a list item. 加入清單專案。
public void AddListItem(ReadOnlyMemory<char> text)
Parameters
textReadOnlyMemory<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
textReadOnlySpan<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
textstringThe 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
textReadOnlyMemory<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
textReadOnlyMemory<char>styleNamestring
AddParagraph(ReadOnlySpan<char>)
Adds a paragraph with the specified rich text runs. 加入一個段落。
public void AddParagraph(ReadOnlySpan<char> text)
Parameters
textReadOnlySpan<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
textReadOnlySpan<char>styleNamestring
AddParagraph(string)
Adds a paragraph with the specified text content. 加入一個段落。
public void AddParagraph(string text)
Parameters
textstring
AddParagraph(string, string?)
Full overload of AddParagraph that accepts text and styleName. AddParagraph 完整多載:接受 text 與 styleName。
public void AddParagraph(string text, string? styleName)
Parameters
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
styleNamestringThe 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
cancellationTokenCancellationTokenThe 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
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
nodeOdfNodeThe DOM node to write. / 要寫入的 DOM 節點。
Exceptions
- ArgumentNullException
Thrown when
nodeis 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 不允許的字元時擲出。