Class OdfPackage
Represents the physical package of an ODF document. 表示 ODF 文件的實體封裝。
public sealed class OdfPackage : IDisposable, IAsyncDisposable
- Inheritance
-
OdfPackage
- Implements
- Inherited Members
Properties
IsFlatXml
Gets a value indicating whether the current package is a single flat XML file. 取得一個值,指出目前封裝是否為單一 Flat XML 檔案。
public bool IsFlatXml { get; set; }
Property Value
Manifest
Gets the media type information list for all entries in the package. 取得封裝內部所有專案的媒體類型資訊清單。
public IReadOnlyDictionary<string, string> Manifest { get; }
Property Value
MediaManager
Gets the media manager instance for this package. 取得此封裝套件的媒體管理器實例。
public OdfMediaManager MediaManager { get; }
Property Value
MimeType
Gets or sets the MIME media type of the ODF package. 取得或設定 ODF 封裝的 MIME 媒體類型。
public string? MimeType { get; }
Property Value
Mode
Gets the open mode of the current ODF package. 取得目前 ODF 封裝的開啟模式。
public OdfPackageMode Mode { get; }
Property Value
RdfMetadata
Gets the package's RDF metadata collection, corresponding to META-INF/manifest.rdf.
取得封裝的 RDF metadata 集合,對應 META-INF/manifest.rdf。
public OdfRdfMetadata RdfMetadata { get; }
Property Value
Version
Gets or sets the ODF specification version of the packaged document. 取得或設定封裝文件的 ODF 規格版本。
public OdfVersion Version { get; set; }
Property Value
Methods
AddEntry(string, byte[])
Adds entry. 將指定的位元組內容新增至封裝;若同名專案已存在,則覆寫該專案。
public void AddEntry(string name, byte[] content)
Parameters
AddEntry(string, byte[], string?)
Short overload of AddEntry that accepts name, content, and mediaType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name、content 與 mediaType;其餘可選參數使用預設值並轉呼叫最長 AddEntry 多載。
public void AddEntry(string name, byte[] content, string? mediaType)
Parameters
AddEntry(string, Stream)
Adds entry. 將指定的資料流內容新增至封裝;若同名專案已存在,則覆寫該專案。
public void AddEntry(string name, Stream contentStream)
Parameters
AddEntry(string, Stream, string?)
Short overload of AddEntry that accepts name, contentStream, and mediaType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name、contentStream 與 mediaType;其餘可選參數使用預設值並轉呼叫最長 AddEntry 多載。
public void AddEntry(string name, Stream contentStream, string? mediaType)
Parameters
Create(Stream)
Creates a new ODF package in the specified stream. 在指定的資料流建立一個新的 ODF 封裝。
public static OdfPackage Create(Stream stream)
Parameters
streamStream
Returns
- OdfPackage
The created OdfPackage instance. / 建立的 OdfPackage 執行個體。
Create(Stream, OdfSaveOptions?)
Short overload of Create that accepts stream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 options;其餘可選參數使用預設值並轉呼叫最長 Create 多載。
public static OdfPackage Create(Stream stream, OdfSaveOptions? options)
Parameters
streamStreamoptionsOdfSaveOptions
Returns
Create(Stream, bool)
Short overload of Create that accepts stream and leaveOpen; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 leaveOpen;其餘可選參數使用預設值並轉呼叫最長 Create 多載。
public static OdfPackage Create(Stream stream, bool leaveOpen)
Parameters
Returns
Create(Stream, bool, OdfSaveOptions?)
Short overload of Create that accepts stream, leaveOpen, and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、leaveOpen 與 options;其餘可選參數使用預設值並轉呼叫最長 Create 多載。
public static OdfPackage Create(Stream stream, bool leaveOpen, OdfSaveOptions? options)
Parameters
streamStreamleaveOpenbooloptionsOdfSaveOptions
Returns
Create(string)
Creates a new ODF package at the specified file path. 在指定的檔案路徑建立一個新的 ODF 封裝。
public static OdfPackage Create(string path)
Parameters
pathstring
Returns
- OdfPackage
The created OdfPackage instance. / 建立的 OdfPackage 執行個體。
Create(string, OdfSaveOptions?)
Short overload of Create that accepts path and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 options;其餘可選參數使用預設值並轉呼叫最長 Create 多載。
public static OdfPackage Create(string path, OdfSaveOptions? options)
Parameters
pathstringoptionsOdfSaveOptions
Returns
Dispose()
Releases unmanaged resources. 釋放 OdfPackage 類別所使用的資源。
public void Dispose()
DisposeAsync()
Releases resources for async. 非同步釋放 OdfPackage 類別所使用的資源。
public ValueTask DisposeAsync()
Returns
- ValueTask
代表非同步處置作業的 ValueTask
DumpVfsLayout()
Performs dump vfs layout. 傳回代表封裝內部虛擬檔案系統(VFS)結構的視覺化佈局字串。
public string DumpVfsLayout()
Returns
- string
VFS 結構的視覺化字串
ExtractObjectStream(string)
Extracts object stream. 擷取內嵌物件的主要內容 XML 資料流。
public Stream ExtractObjectStream(string objectName)
Parameters
objectNamestring內嵌物件的路徑名稱
Returns
- Stream
內嵌物件內容的資料流
FindEntryEncryptionInfo(string)
Finds the encryption details of the specified entry. 尋找指定專案的加密詳細資訊。
public OdfEncryptionInfo? FindEntryEncryptionInfo(string name)
Parameters
namestringThe relative path name of the entry. / 專案的相對路徑名稱。
Returns
- OdfEncryptionInfo
The entry's encryption information, or null if not encrypted. / 專案的加密資訊;若未加密則為 null。
GetEmbeddedObjects()
Gets embedded objects. 取得此封裝中所內嵌的 ODF 物件資料夾路徑清單。
public IEnumerable<string> GetEmbeddedObjects()
Returns
- IEnumerable<string>
內嵌物件路徑的集合
GetEntries()
Gets entries. 取得封裝中所有實體專案的資訊集合。
public IEnumerable<OdfPackage.OdfPackageEntryInfo> GetEntries()
Returns
- IEnumerable<OdfPackage.OdfPackageEntryInfo>
所有專案的資訊集合
GetEntryStream(string)
Gets entry stream. 取得指定專案的唯讀資料流。
public Stream GetEntryStream(string name)
Parameters
namestring專案的相對路徑名稱
Returns
- Stream
代表專案內容的資料流
HasEntry(string)
Returns whether this instance is entry is present. 檢查封裝中是否包含指定名稱的專案。
public bool HasEntry(string name)
Parameters
namestring專案的相對路徑名稱
Returns
IsEntryEncrypted(string)
Determines whether the entry at the specified path is encrypted. 判斷指定路徑的專案是否已加密。
public bool IsEntryEncrypted(string name)
Parameters
namestringThe relative path name of the entry. / 專案的相對路徑名稱。
Returns
LoadEncryptedAsync(Stream, string, bool, CancellationToken)
Asynchronously loads and decrypts an ODF package from the specified stream. 非同步從指定資料流載入並解密 ODF 封裝。
public static Task<OdfPackage> LoadEncryptedAsync(Stream stream, string password, bool leaveOpen, CancellationToken cancellationToken)
Parameters
streamStreamThe stream containing the ODF package. / 包含 ODF 封裝的資料流。
passwordstringThe password used to decrypt the package. / 用於解密封裝的密碼。
leaveOpenboolA value indicating whether disposal leaves the stream open. / 指出處置封裝時是否保持資料流開啟。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfPackage>
A task whose result is the decrypted package. / 工作結果為已解密封裝。
LoadEncryptedAsync(string, string, CancellationToken)
Asynchronously loads and decrypts an ODF package from the specified path. 非同步從指定路徑載入並解密 ODF 封裝。
public static Task<OdfPackage> LoadEncryptedAsync(string path, string password, CancellationToken cancellationToken)
Parameters
pathstringThe ODF package path. / ODF 封裝路徑。
passwordstringThe password used to decrypt the package. / 用於解密封裝的密碼。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfPackage>
A task whose result is the decrypted package. / 工作結果為已解密封裝。
Open(Stream)
Opens an existing ODF package from the specified stream. 從指定的資料流開啟既有的 ODF 封裝。
public static OdfPackage Open(Stream stream)
Parameters
streamStream
Returns
- OdfPackage
The opened OdfPackage instance. / 開啟的 OdfPackage 執行個體。
Remarks
When lazy loading is enabled, this method starts a background task that reads well-known entries (e.g. content.xml, styles.xml, meta.xml, settings.xml) from stream; Dispose() and DisposeAsync() both wait for this task to finish. Callers that pass true for must fully dispose the returned OdfPackage (e.g. by scoping it in an explicit using block) before repositioning or reopening the same stream; otherwise the background read and a subsequent foreground read race on the stream's cursor and can corrupt the read.
啟用延遲載入時,此方法會啟動一個背景工作,從 stream 讀取已知專案(例如 content.xml、styles.xml、meta.xml、settings.xml);Dispose() 與 DisposeAsync() 都會等待此工作完成。呼叫端若對 傳入 true,必須在重新定位或重新開啟同一個 stream 之前完整釋放傳回的 OdfPackage(例如以明確的 using 區塊限定其存活範圍),否則背景讀取與後續的前景讀取會競爭該資料流的游標,可能導致讀取內容毀損。
Open(Stream, OdfLoadOptions?)
Short overload of Open that accepts stream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 options;其餘可選參數使用預設值並轉呼叫最長 Open 多載。
public static OdfPackage Open(Stream stream, OdfLoadOptions? options)
Parameters
streamStreamoptionsOdfLoadOptions
Returns
Open(Stream, bool)
Short overload of Open that accepts stream and leaveOpen; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 leaveOpen;其餘可選參數使用預設值並轉呼叫最長 Open 多載。
public static OdfPackage Open(Stream stream, bool leaveOpen)
Parameters
Returns
Open(Stream, bool, OdfLoadOptions?)
Short overload of Open that accepts stream, leaveOpen, and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、leaveOpen 與 options;其餘可選參數使用預設值並轉呼叫最長 Open 多載。
public static OdfPackage Open(Stream stream, bool leaveOpen, OdfLoadOptions? options)
Parameters
streamStreamleaveOpenbooloptionsOdfLoadOptions
Returns
Open(string)
Opens an existing ODF package from the specified file path. 從指定的檔案路徑開啟既有的 ODF 封裝。
public static OdfPackage Open(string path)
Parameters
pathstring
Returns
- OdfPackage
The opened OdfPackage instance. / 開啟的 OdfPackage 執行個體。
Open(string, OdfLoadOptions?)
Short overload of Open that accepts path and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 options;其餘可選參數使用預設值並轉呼叫最長 Open 多載。
public static OdfPackage Open(string path, OdfLoadOptions? options)
Parameters
pathstringoptionsOdfLoadOptions
Returns
OpenAsync(Stream)
Asynchronously opens an existing ODF package from the specified stream. 非同步從指定的資料流開啟既有的 ODF 封裝。
public static Task<OdfPackage> OpenAsync(Stream stream)
Parameters
streamStream
Returns
- Task<OdfPackage>
A task representing the asynchronous open operation, whose result is the opened OdfPackage instance. / 代表非同步開啟作業的工作,其結果為開啟的 OdfPackage 執行個體。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與 manifest 載入期間協作檢查取消語彙。
OpenAsync(Stream, OdfLoadOptions?)
Short overload of OpenAsync that accepts stream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 options;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(Stream stream, OdfLoadOptions? options)
Parameters
streamStreamoptionsOdfLoadOptions
Returns
OpenAsync(Stream, bool)
Short overload of OpenAsync that accepts stream and leaveOpen; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 leaveOpen;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(Stream stream, bool leaveOpen)
Parameters
Returns
OpenAsync(Stream, bool, OdfLoadOptions?)
Short overload of OpenAsync that accepts stream, leaveOpen, and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、leaveOpen 與 options;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(Stream stream, bool leaveOpen, OdfLoadOptions? options)
Parameters
streamStreamleaveOpenbooloptionsOdfLoadOptions
Returns
OpenAsync(Stream, bool, OdfLoadOptions?, CancellationToken)
Short overload of OpenAsync that accepts stream, leaveOpen, options, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、leaveOpen、options 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(Stream stream, bool leaveOpen, OdfLoadOptions? options, CancellationToken cancellationToken)
Parameters
streamStreamleaveOpenbooloptionsOdfLoadOptionscancellationTokenCancellationToken
Returns
OpenAsync(Stream, bool, CancellationToken)
Asynchronously opens an ODF package from a stream with leave-open and cancellation options. 以是否保持資料流開啟與取消語彙基元非同步從資料流開啟 ODF 封裝。
public static Task<OdfPackage> OpenAsync(Stream stream, bool leaveOpen, CancellationToken cancellationToken)
Parameters
streamStreamThe package stream. / 封裝資料流。
leaveOpenboolWhether to leave the stream open. / 是否保持資料流開啟。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfPackage>
A task whose result is the opened package. / 代表非同步開啟作業的工作,其結果為已開啟的封裝。
OpenAsync(Stream, CancellationToken)
Asynchronously opens an ODF package from a stream with a cancellation token. 以取消語彙基元非同步從資料流開啟 ODF 封裝。
public static Task<OdfPackage> OpenAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe package stream. / 封裝資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfPackage>
A task whose result is the opened package. / 代表非同步開啟作業的工作,其結果為已開啟的封裝。
OpenAsync(string)
Asynchronously opens an existing ODF package from the specified file path. 非同步從指定的檔案路徑開啟既有的 ODF 封裝。
public static Task<OdfPackage> OpenAsync(string path)
Parameters
pathstring
Returns
- Task<OdfPackage>
A task representing the asynchronous open operation, whose result is the opened OdfPackage instance. / 代表非同步開啟作業的工作,其結果為開啟的 OdfPackage 執行個體。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與 manifest 載入期間協作檢查取消語彙。
OpenAsync(string, OdfLoadOptions?)
Short overload of OpenAsync that accepts path and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 options;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(string path, OdfLoadOptions? options)
Parameters
pathstringoptionsOdfLoadOptions
Returns
OpenAsync(string, OdfLoadOptions?, CancellationToken)
Short overload of OpenAsync that accepts path, options, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path、options 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 OpenAsync 多載。
public static Task<OdfPackage> OpenAsync(string path, OdfLoadOptions? options, CancellationToken cancellationToken)
Parameters
pathstringoptionsOdfLoadOptionscancellationTokenCancellationToken
Returns
OpenAsync(string, CancellationToken)
Asynchronously opens an ODF package from a file path with a cancellation token. 以取消語彙基元非同步從檔案路徑開啟 ODF 封裝。
public static Task<OdfPackage> OpenAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringThe package file path. / 封裝檔案路徑。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<OdfPackage>
A task whose result is the opened package. / 代表非同步開啟作業的工作,其結果為已開啟的封裝。
PruneUnusedMedia(IEnumerable<string>)
Performs prune unused media. 清理封裝中未被參照的圖片等媒體檔案。
public void PruneUnusedMedia(IEnumerable<string> referencedMediaPaths)
Parameters
referencedMediaPathsIEnumerable<string>所有目前正被參照的媒體檔案路徑集合
Remarks
此方法僅依路徑清單比對移除 Pictures/ 下的 ZIP 媒體專案,不會檢查或同步移除
content.xml/styles.xml 中殘留的 draw:image DOM 參照節點。
呼叫端必須自行確保 referencedMediaPaths 與目前 DOM 實際參照狀態一致,
否則殘留的 DOM 參照會指向已被刪除的媒體專案而形成懸空連結,可能導致真實 ODF 應用程式
(例如 LibreOffice)拒絕開啟整份文件。
RawEntryPatch(string, OdfRawEntryPatcher)
Performs raw entry patch. 支援免 DOM 解析的原始二進位直改。
public bool RawEntryPatch(string entryName, OdfRawEntryPatcher patcher)
Parameters
entryNamestring專案的相對路徑名稱
patcherOdfRawEntryPatcher直改委派,傳入原始內容 ReadOnlySpan,寫入目標 IBufferWriter,回傳是否發生變更
Returns
- bool
是否確實發生變更
ReadEntry(string)
Reads entry. 讀取指定路徑專案的完整內容位元組。
public byte[] ReadEntry(string path)
Parameters
pathstring專案的相對路徑名稱
Returns
- byte[]
專案的位元組陣列內容
RemoveEntry(string)
Removes the specified entry from the package. 從封裝中移除指定的專案。
public bool RemoveEntry(string name)
Parameters
namestringThe relative package entry path to remove. / 要移除的專案相對路徑名稱。
Returns
- bool
true if an entry, manifest item, or entry-order item was removed; otherwise, false. / 若已移除 entry、manifest 項目或 entry order 項目則為 true;否則為 false。
SanitizeEntryName(string)
Performs sanitize entry name. 清理並驗證 ZIP 項目名稱,防止目錄穿越攻擊(Zip Slip 漏洞防禦)。
public static string SanitizeEntryName(string name)
Parameters
namestring原始專案名稱
Returns
- string
淨化後的標準專案名稱
SanitizeMacros()
Performs sanitize macros. 淨化封裝以移除所有 VBA、StarBasic 巨集指令碼、簽章以及指令碼參考。
public void SanitizeMacros()
SanitizeXmlNode(OdfNode)
Performs sanitize xml node. 遞迴淨化指定的 XML 節點,移除事件監聽器與巨集或指令碼屬性。
public static bool SanitizeXmlNode(OdfNode node)
Parameters
nodeOdfNode要淨化的 ODF 節點
Returns
Save()
Performs the Save operation. 將所有變更儲存回原來的檔案或資料流中。
public void Save()
Save(OdfSaveOptions?)
Full overload of Save that accepts options. Save 完整多載:接受 options。
public void Save(OdfSaveOptions? options)
Parameters
optionsOdfSaveOptions
Save(IBufferWriter<byte>)
Performs the Save operation. 將封裝序列化儲存至指定的位元組緩衝區寫入器。
public void Save(IBufferWriter<byte> destination)
Parameters
destinationIBufferWriter<byte>
Remarks
此入口會將 ZIP 或 Flat XML 輸出直接寫入 destination,適合與 ASP.NET Core、
pipelines 或自訂零拷貝緩衝區整合,避免呼叫端必須先建立中介 MemoryStream。
Save(IBufferWriter<byte>, OdfSaveOptions?)
Full overload of Save that accepts destination and options. Save 完整多載:接受 destination 與 options。
public void Save(IBufferWriter<byte> destination, OdfSaveOptions? options)
Parameters
destinationIBufferWriter<byte>optionsOdfSaveOptions
Save(Stream)
Performs the Save operation. 將目前 ODF 封裝儲存到指定的目標資料流中。
public void Save(Stream stream)
Parameters
streamStream
Save(Stream, OdfSaveOptions?)
Full overload of Save that accepts stream and options. Save 完整多載:接受 stream 與 options。
public void Save(Stream stream, OdfSaveOptions? options)
Parameters
streamStreamoptionsOdfSaveOptions
SaveAsync()
Saves async. 將所有變更儲存回原來的檔案或資料流中(非同步)。
public Task SaveAsync()
Returns
- Task
代表非同步作業的工作
SaveAsync(OdfSaveOptions?)
Short overload of SaveAsync that accepts options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 options;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public Task SaveAsync(OdfSaveOptions? options)
Parameters
optionsOdfSaveOptions
Returns
SaveAsync(OdfSaveOptions?, CancellationToken)
Saves async. 使用指定儲存選項,將所有變更儲存回原來的檔案或資料流中(非同步)。
public Task SaveAsync(OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
optionsOdfSaveOptions單次儲存設定選項;若為 null,則使用封裝預設選項
cancellationTokenCancellationToken取消語彙
Returns
- Task
代表非同步作業的工作
Remarks
若 cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束;
否則會在 ZIP 寫入與串流 I/O 期間協作檢查取消語彙。
SaveAsync(CancellationToken)
Short overload of SaveAsync that accepts cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 SaveAsync 多載。
public Task SaveAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
SaveEncryptedAsync(Stream, string, OdfEncryptionAlgorithm, CancellationToken)
Asynchronously saves the package to the specified stream with password encryption. 非同步以密碼加密並將封裝儲存至指定資料流。
public Task SaveEncryptedAsync(Stream destinationStream, string password, OdfEncryptionAlgorithm algorithm, CancellationToken cancellationToken)
Parameters
destinationStreamStreamThe destination stream. / 目的地資料流。
passwordstringThe password used to encrypt the package. / 用於加密封裝的密碼。
algorithmOdfEncryptionAlgorithmThe encryption algorithm to use. / 要使用的加密演算法。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveEncryptedAsync(string, OdfEncryptionAlgorithm, CancellationToken)
Asynchronously saves the package to its original destination with password encryption. 非同步以密碼加密並將封裝儲存至原始目的地。
public Task SaveEncryptedAsync(string password, OdfEncryptionAlgorithm algorithm, CancellationToken cancellationToken)
Parameters
passwordstringThe password used to encrypt the package. / 用於加密封裝的密碼。
algorithmOdfEncryptionAlgorithmThe encryption algorithm to use. / 要使用的加密演算法。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task
A task representing the asynchronous save operation. / 代表非同步儲存作業的工作。
SaveToStream(Stream)
Saves to stream. 將封裝序列化儲存至指定的目的地資料流。
public void SaveToStream(Stream destinationStream)
Parameters
destinationStreamStream
SaveToStream(Stream, OdfSaveOptions?)
Full overload of SaveToStream that accepts destinationStream and options. SaveToStream 完整多載:接受 destinationStream 與 options。
public void SaveToStream(Stream destinationStream, OdfSaveOptions? options)
Parameters
destinationStreamStreamoptionsOdfSaveOptions
SaveToStreamAsync(Stream)
Saves to stream async. 將封裝序列化儲存至指定的目的地資料流(非同步)。
public Task SaveToStreamAsync(Stream destinationStream)
Parameters
destinationStreamStream
Returns
- Task
代表非同步作業的工作
SaveToStreamAsync(Stream, OdfSaveOptions?)
Short overload of SaveToStreamAsync that accepts destinationStream and options; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 destinationStream 與 options;其餘可選參數使用預設值並轉呼叫最長 SaveToStreamAsync 多載。
public Task SaveToStreamAsync(Stream destinationStream, OdfSaveOptions? options)
Parameters
destinationStreamStreamoptionsOdfSaveOptions
Returns
SaveToStreamAsync(Stream, OdfSaveOptions?, CancellationToken)
Saves to stream async. 使用指定儲存選項,將封裝序列化儲存至指定的目的地資料流(非同步)。
public Task SaveToStreamAsync(Stream destinationStream, OdfSaveOptions? options, CancellationToken cancellationToken)
Parameters
destinationStreamStream目標目的地資料流
optionsOdfSaveOptions單次儲存設定選項;若為 null,則使用封裝預設選項
cancellationTokenCancellationToken取消語彙
Returns
- Task
代表非同步作業的工作
Remarks
若 cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束;
否則會在 ZIP 寫入與串流 I/O 期間協作檢查取消語彙。
SaveToStreamAsync(Stream, CancellationToken)
Short overload of SaveToStreamAsync that accepts destinationStream and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 destinationStream 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 SaveToStreamAsync 多載。
public Task SaveToStreamAsync(Stream destinationStream, CancellationToken cancellationToken)
Parameters
destinationStreamStreamcancellationTokenCancellationToken
Returns
SetMimeType(string)
Sets mime type. 設定 ODF 封裝的主要 MIME 媒體類型。
public void SetMimeType(string mimetype)
Parameters
mimetypestring媒體類型字串
SyncRdfMetadataWithEntries()
Performs sync rdf metadata with entries.
將 RdfMetadata 中的 pkg:hasPart 與 pkg:mimeType 與目前封裝項目同步。
public int SyncRdfMetadataWithEntries()
Returns
- int
新增或更新的 triple 數量
WriteEntry(string, byte[])
Writes entry. 將指定的位元組內容寫入或覆寫封裝中的專案。
public void WriteEntry(string name, byte[] content)
Parameters
WriteEntry(string, byte[], string?)
Short overload of WriteEntry that accepts name, content, and mediaType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name、content 與 mediaType;其餘可選參數使用預設值並轉呼叫最長 WriteEntry 多載。
public void WriteEntry(string name, byte[] content, string? mediaType)
Parameters
WriteEntry(string, Stream)
Writes entry. 將指定的資料流內容寫入或覆寫封裝中的專案。
public void WriteEntry(string name, Stream contentStream)
Parameters
WriteEntry(string, Stream, string?)
Short overload of WriteEntry that accepts name, contentStream, and mediaType; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name、contentStream 與 mediaType;其餘可選參數使用預設值並轉呼叫最長 WriteEntry 多載。
public void WriteEntry(string name, Stream contentStream, string? mediaType)