目錄 / Table of Contents

Class SpreadsheetDocument

Namespace
OdfKit.Spreadsheet
Assembly
OdfKit.dll

Provides the SpreadsheetDocument API. 提供 SpreadsheetDocument API。

public class SpreadsheetDocument : OdfDocument, IDisposable, IAsyncDisposable
Inheritance
SpreadsheetDocument
Implements
Derived
Inherited Members

Constructors

SpreadsheetDocument(OdfPackage)

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

public SpreadsheetDocument(OdfPackage package)

Parameters

package OdfPackage

The ODF package. / Odf 套件包。

Properties

CalculationSettings

Gets the workbook-level formula calculation and recalculation settings for the ODS spreadsheet. 取得 ODS 活頁簿層級的公式計算與重算設定。

public OdfSpreadsheetCalculationSettings CalculationSettings { get; }

Property Value

OdfSpreadsheetCalculationSettings

Gets whether the spreadsheet contains formula DDE link declarations. 取得試算表是否包含公式 DDE 連結宣告。

public bool ContainsDdeLinks { get; }

Property Value

bool

This property only inspects document markup and never connects to a DDE server. 此屬性只檢查文件標記,絕不連線至 DDE 伺服器。

Gets the external link manager for cross-document formula references. 取得跨文件公式引用的外部連結管理器。

public OdfExternalLinkManager ExternalLinks { get; }

Property Value

OdfExternalLinkManager

TrackedChanges

Gets or sets a value indicating whether spreadsheet change tracking is enabled. 取得或設定一個值,指出是否啟用試算表追蹤修訂。

public bool TrackedChanges { get; set; }

Property Value

bool

WorkbookStructureProtected

Gets a value indicating whether the workbook structure is protected. 取得一個值,指出活頁簿結構是否受到保護。

public bool WorkbookStructureProtected { get; }

Property Value

bool

Worksheets

Gets the worksheet collection. 取得工作表集合。

public OdfWorksheetCollection Worksheets { get; }

Property Value

OdfWorksheetCollection

Methods

AcceptAllChanges()

Accepts all pending tracked changes. 接受所有待處理的追蹤修訂。

public void AcceptAllChanges()

AcceptChange(string)

Accepts the specified tracked change. 接受指定的追蹤修訂。

public void AcceptChange(string changeId)

Parameters

changeId string

The change identifier. / 修訂識別碼。

AddChart(string, OdfCellAddress, OdfChartDefinition)

Inserts a chart at the specified cell position in a worksheet. 在指定工作表的儲存格位置插入圖表。

public void AddChart(string sheetName, OdfCellAddress anchor, OdfChartDefinition chart)

Parameters

sheetName string

The name or identifier. / 工作表名稱

anchor OdfCellAddress

The cell address. / 圖表左上角錨定的儲存格位置

chart OdfChartDefinition

The value to use. / 圖表設定物件

AddChart(string, OdfCellAddress, OdfChartDefinition, OdfLength, OdfLength)

Inserts a chart at the specified cell position in a worksheet with custom dimensions. 在指定工作表的儲存格位置插入圖表(支援自訂寬高)。

public OdfNode AddChart(string sheetName, OdfCellAddress anchor, OdfChartDefinition chart, OdfLength width, OdfLength height)

Parameters

sheetName string

The name or identifier. / 工作表名稱

anchor OdfCellAddress

The cell address. / 圖表左上角錨定的儲存格位置

chart OdfChartDefinition

The value to use. / 圖表設定物件

width OdfLength

The value to use. / 圖表寬度

height OdfLength

The value to use. / 圖表高度

Returns

OdfNode

The result. / 代表圖表物件的 OdfNode 節點

AddChartFromRange(string, OdfCellAddress, OdfCellRange)

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

public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range)

Parameters

sheetName string
anchor OdfCellAddress
range OdfCellRange

Returns

OdfNode

AddChartFromRange(string, OdfCellAddress, OdfCellRange, OdfChartPreset)

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

public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfChartPreset preset)

Parameters

sheetName string
anchor OdfCellAddress
range OdfCellRange
preset OdfChartPreset

Returns

OdfNode

AddChartFromRange(string, OdfCellAddress, OdfCellRange, OdfChartPreset, string?)

Inserts a practical preset chart bound to a worksheet range. 插入繫結至工作表範圍的實務預設圖表。

public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfChartPreset preset, string? title)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

anchor OdfCellAddress

The top-left anchor cell. / 左上角錨定儲存格。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

preset OdfChartPreset

The chart preset. / 圖表預設。

title string

The optional chart title. / 選用的圖表標題。

Returns

OdfNode

The created frame node. / 建立完成的框架節點。

AddDataValidation(string, OdfDataValidation)

Adds a data validation rule to the specified worksheet. 在指定的工作表中新增資料驗證規則。

public void AddDataValidation(string sheetName, OdfDataValidation validation)

Parameters

sheetName string

The name or identifier. / 工作表名稱

validation OdfDataValidation

The value to use. / 資料驗證設定物件

AddDatabaseRange(string, OdfCellRange)

Adds a database range. 新增資料庫範圍。

public OdfDatabaseRange AddDatabaseRange(string name, OdfCellRange range)

Parameters

name string

The name or identifier. / 資料庫範圍名稱

range OdfCellRange

The cell range. / 目標儲存格範圍

Returns

OdfDatabaseRange

The result. / 新增的 OdfDatabaseRange 執行個體

AddImageFrame(string, OdfCellAddress, byte[], OdfLength, OdfLength)

Short overload of AddImageFrame that accepts sheetName, anchor, imageBytes, width, and height; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName、anchor、imageBytes、width 與 height;其餘可選參數使用預設值並轉呼叫最長 AddImageFrame 多載。

public OdfImage AddImageFrame(string sheetName, OdfCellAddress anchor, byte[] imageBytes, OdfLength width, OdfLength height)

Parameters

sheetName string
anchor OdfCellAddress
imageBytes byte[]
width OdfLength
height OdfLength

Returns

OdfImage

AddImageFrame(string, OdfCellAddress, byte[], OdfLength, OdfLength, string?)

Inserts an image frame at the specified cell position in a worksheet. 在指定工作表的儲存格位置插入影像框架。

public OdfImage AddImageFrame(string sheetName, OdfCellAddress anchor, byte[] imageBytes, OdfLength width, OdfLength height, string? name)

Parameters

sheetName string

The name or identifier. / 工作表名稱

anchor OdfCellAddress

The cell address. / 影像左上角錨定的儲存格位置

imageBytes byte[]

The value to use. / 影像的二進位資料位元組

width OdfLength

The value to use. / 影像寬度

height OdfLength

The value to use. / 影像高度

name string

The name or identifier. / 影像名稱

Returns

OdfImage

The result. / 代表新建立影像框架的 OdfImage 物件

AddNamedExpression(string, string)

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

public void AddNamedExpression(string name, string expression)

Parameters

name string
expression string

AddNamedExpression(string, string, OdfCellAddress?)

Adds a named expression. 新增具名運算式。

public void AddNamedExpression(string name, string expression, OdfCellAddress? baseCell)

Parameters

name string

The name or identifier. / 具名運算式的名稱

expression string

The value to use. / 公式運算式字串

baseCell OdfCellAddress?

The cell address. / 基準儲存格位址

AddNamedRange(string, OdfCellRange)

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

public void AddNamedRange(string name, OdfCellRange range)

Parameters

name string
range OdfCellRange

AddNamedRange(string, OdfCellRange, OdfCellAddress?)

Adds a named range. 新增命名範圍。

public void AddNamedRange(string name, OdfCellRange range, OdfCellAddress? baseCell)

Parameters

name string

The name or identifier. / 命名範圍的名稱

range OdfCellRange

The cell range. / 儲存格範圍

baseCell OdfCellAddress?

The cell address. / 基準儲存格位址

AddSheet(string)

Adds a worksheet with the specified name. 新增指定名稱的工作表。

public OdfTableSheet AddSheet(string name)

Parameters

name string

The name or identifier. / 工作表名稱

Returns

OdfTableSheet

The result. / 新增的 OdfTableSheet 執行個體

AdoptSheet(OdfTableSheet)

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

public OdfTableSheet AdoptSheet(OdfTableSheet sheet)

Parameters

sheet OdfTableSheet

Returns

OdfTableSheet

AdoptSheet(OdfTableSheet, string?)

Adopts a worksheet from another document or the same document at the end of this workbook. 將另一份文件或同一份文件中的工作表採納到此活頁簿末尾。

public OdfTableSheet AdoptSheet(OdfTableSheet sheet, string? newName)

Parameters

sheet OdfTableSheet

The value to use. / 要採納的來源工作表

newName string

The name or identifier. / 採納後選用的新工作表名稱;未指定時保留來源名稱

Returns

OdfTableSheet

The result. / 採納完成且屬於此文件的工作表

Remarks

此方法沿用 AdoptNode(OdfDocument, OdfNode) 的低分配採納路徑, 會將來源工作表節點自原本活頁簿移除、遷移媒體參照,並更新節點文件所有權與命名空間前綴。

Exceptions

ArgumentNullException

Thrown when the documented condition occurs. / 當 sheetnull 時擲出

AppendObjects<T>(string, IEnumerable<T>)

Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。

public OdfObjectBindingReport AppendObjects<T>(string sheetName, IEnumerable<T> items)

Parameters

sheetName string
items IEnumerable<T>

Returns

OdfObjectBindingReport

Type Parameters

T

AppendObjects<T>(string, IEnumerable<T>, OdfObjectBindingOptions?)

Appends public readable object properties after the used range of the specified worksheet. 將物件的可讀公開屬性附加到指定工作表已使用範圍之後。

public OdfObjectBindingReport AppendObjects<T>(string sheetName, IEnumerable<T> items, OdfObjectBindingOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

items IEnumerable<T>

The object sequence to append. / 要附加的物件序列。

options OdfObjectBindingOptions

The object binding options. / 物件繫結選項。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The object type to append. / 要附加的物件型別。

AppendRows(string, IEnumerable<IEnumerable<object?>>)

Appends rows after the current used range in the specified worksheet. 將資料列附加到指定工作表目前已使用範圍之後。

public OdfCellRange AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

rows IEnumerable<IEnumerable<object>>

The row values to append. / 要附加的資料列。

Returns

OdfCellRange

The appended range. / 已附加的範圍。

AppendRows(string, IEnumerable<IEnumerable<object?>>, int)

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

public OdfCellRange AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows, int startColumn)

Parameters

sheetName string
rows IEnumerable<IEnumerable<object>>
startColumn int

Returns

OdfCellRange

AppendRows(string, IEnumerable<IEnumerable<object?>>, int, OdfRangeWriteOptions?)

Appends rows after the current used range in the specified worksheet and returns a write report. 將資料列附加到指定工作表目前已使用範圍之後並傳回寫入報告。

public OdfRangeWriteReport AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows, int startColumn, OdfRangeWriteOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

rows IEnumerable<IEnumerable<object>>

The row values to append. / 要附加的資料列。

startColumn int

The zero-based start column. / 以 0 為基準的起始欄。

options OdfRangeWriteOptions

The range write options. / 範圍寫入選項。

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

BeginFormulaEvaluationChannel()

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

public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel()

Returns

OdfFormulaEvaluationChannel

BeginFormulaEvaluationChannel(int)

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

public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel(int capacity)

Parameters

capacity int

Returns

OdfFormulaEvaluationChannel

BeginFormulaEvaluationChannel(int, CancellationToken)

Opens an asynchronous formula recalculation channel that queues subsequent cell value or formula changes for background recalculation. 開啟非同步公式重算通道,將後續儲存格值或公式變更排入背景重算。

public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel(int capacity, CancellationToken cancellationToken)

Parameters

capacity int

The channel capacity. / 通道容量。

cancellationToken CancellationToken

The cancellation token. / 取消語彙基元。

Returns

OdfFormulaEvaluationChannel

The started formula recalculation channel. / 已啟動的公式重算通道。

Builder()

Creates a new ODS spreadsheet document fluent builder. 建立新的 ODS 試算表文件 Fluent builder。

public static SpreadsheetDocumentBuilder Builder()

Returns

SpreadsheetDocumentBuilder

A new SpreadsheetDocumentBuilder instance. / 新的 SpreadsheetDocumentBuilder 執行個體。

ClearDataValidations()

Removes all data validation rules and detaches every referencing cell while preserving unknown container content. 移除所有資料驗證規則並解除全部引用儲存格的關聯,同時保留容器中的未知內容。

public int ClearDataValidations()

Returns

int

The number of removed rules. / 已移除的規則數量。

ClearDatabaseRanges()

Removes all database ranges while preserving named ranges and unknown content in the container. 移除所有資料庫範圍,並保留容器中的命名範圍及未知內容。

public int ClearDatabaseRanges()

Returns

int

The number removed. / 移除數量。

ClearEmbeddedCharts()

Removes all embedded charts and their package subdocuments. 移除所有嵌入圖表及其封裝子文件。

public int ClearEmbeddedCharts()

Returns

int

The number of removed embedded charts. / 已移除的嵌入圖表數量。

ClearPivotTables()

Removes all pivot table definitions while preserving unknown container content and cached worksheet output cells. 移除所有樞紐分析表定義,並保留容器中的未知內容與工作表快取輸出儲存格。

public int ClearPivotTables()

Returns

int

The number removed. / 移除數量。

ClearTemplateUserContent()

Clears template user content. 清除 Template User Content。

protected override void ClearTemplateUserContent()

Remarks

基底實作不做任何事;各文件種類(文字、試算表、簡報、繪圖)於對應的部分類別中覆寫, 依各自的內容模型清除使用者資料。

Create()

Creates a new ODS spreadsheet document. 建立新的 ODS 試算表文件。

public static SpreadsheetDocument Create()

Returns

SpreadsheetDocument

A new SpreadsheetDocument instance. / 新的 SpreadsheetDocument 執行個體。

CreateFormulaEvaluationSession()

Creates an incremental formula evaluation session with default safety limits. 使用預設安全限制建立增量公式評估工作階段。

public OdfFormulaEvaluationSession CreateFormulaEvaluationSession()

Returns

OdfFormulaEvaluationSession

The document-bound incremental evaluation session. / 繫結至文件的增量評估工作階段。

CreateFormulaEvaluationSession(OdfFormulaEvaluationOptions)

Creates an incremental formula evaluation session with explicit safety limits. 使用明確的安全限制建立增量公式評估工作階段。

public OdfFormulaEvaluationSession CreateFormulaEvaluationSession(OdfFormulaEvaluationOptions options)

Parameters

options OdfFormulaEvaluationOptions

The formula evaluation options. / 公式評估選項。

Returns

OdfFormulaEvaluationSession

The document-bound incremental evaluation session. / 繫結至文件的增量評估工作階段。

Exceptions

ArgumentNullException

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

CreateFromFlatDocument(FlatSpreadsheetDocument)

Creates an equivalent ODS (ZIP package) spreadsheet document from a FODS flat XML spreadsheet document, with identical content. 從 FODS 扁平 XML 試算表文件建立等價的 ODS(ZIP 封裝)試算表文件,內容完全相同。

public static SpreadsheetDocument CreateFromFlatDocument(FlatSpreadsheetDocument document)

Parameters

document FlatSpreadsheetDocument

The source FODS flat XML spreadsheet document. / 來源 FODS 扁平 XML 試算表文件。

Returns

SpreadsheetDocument

The created SpreadsheetDocument instance. / 建立完成的 SpreadsheetDocument 執行個體。

CreateFromTemplate(SpreadsheetTemplateDocument)

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

public static SpreadsheetDocument CreateFromTemplate(SpreadsheetTemplateDocument template)

Parameters

template SpreadsheetTemplateDocument

Returns

SpreadsheetDocument

CreateFromTemplate(SpreadsheetTemplateDocument, bool)

Creates a new spreadsheet document from the specified spreadsheet template. 從指定的試算表範本文件建立新的試算表文件。

public static SpreadsheetDocument CreateFromTemplate(SpreadsheetTemplateDocument template, bool clearUserContent)

Parameters

template SpreadsheetTemplateDocument

The spreadsheet template document. / 試算表範本文件。

clearUserContent bool

Whether to clear the data rows of each sheet in the template while keeping column widths and sheet structure. / 是否清除範本中各工作表的資料列,但保留欄寬與工作表結構。

Returns

SpreadsheetDocument

The created SpreadsheetDocument instance. / 建立完成的 SpreadsheetDocument 執行個體。

CreateTable(string, OdfCellRange)

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

public OdfSpreadsheetTable CreateTable(string name, OdfCellRange range)

Parameters

name string
range OdfCellRange

Returns

OdfSpreadsheetTable

CreateTable(string, OdfCellRange, OdfSpreadsheetTableOptions?)

Creates a practical spreadsheet table backed by an ODF database range. 建立由 ODF 資料庫範圍支援的實務試算表表格。

public OdfSpreadsheetTable CreateTable(string name, OdfCellRange range, OdfSpreadsheetTableOptions? options)

Parameters

name string

The table name. / 表格名稱。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

options OdfSpreadsheetTableOptions

The table options. / 表格選項。

Returns

OdfSpreadsheetTable

The editable table facade. / 可編輯的表格 facade。

Dispose(bool)

Releases unmanaged resources. 釋放非受控資源。

protected override void Dispose(bool disposing)

Parameters

disposing bool

If true, managed resources are released. / 若為 true,則釋放受控資源。

EvaluateFormulas()

Evaluates formulas in the current spreadsheet document and resolves cross-document references with ExternalLinks. 評估目前試算表文件中的公式,並使用 ExternalLinks 解析跨文件參照。

public OdfFormulaEvaluationReport EvaluateFormulas()

Returns

OdfFormulaEvaluationReport

EvaluateFormulas(DefaultFormulaEvaluator)

Evaluates formulas with a configured evaluator, including its custom functions and fallback. 使用已設定的評估器計算公式,包含其自訂函式與後援。

public OdfFormulaEvaluationReport EvaluateFormulas(DefaultFormulaEvaluator evaluator)

Parameters

evaluator DefaultFormulaEvaluator

The configured formula evaluator. / 已設定的公式評估器。

Returns

OdfFormulaEvaluationReport

EvaluateFormulas(OdfFormulaEvaluationOptions)

Evaluates formulas transactionally with explicit security and resource limits. 使用明確的安全與資源限制,以交易方式評估公式。

public OdfFormulaEvaluationReport EvaluateFormulas(OdfFormulaEvaluationOptions options)

Parameters

options OdfFormulaEvaluationOptions

The formula evaluation options. / 公式評估選項。

Returns

OdfFormulaEvaluationReport

The evaluation report. / 評估報告。

Exceptions

ArgumentNullException

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

OdfFormulaEvaluationException

Thrown when strict evaluation fails. / 當嚴格評估失敗時擲出。

EvaluateFormulas(OdfFormulaEvaluationOptions, CancellationToken)

Evaluates formulas transactionally with explicit limits and cancellation. 使用明確限制與取消權杖,以交易方式評估公式。

public OdfFormulaEvaluationReport EvaluateFormulas(OdfFormulaEvaluationOptions options, CancellationToken cancellationToken)

Parameters

options OdfFormulaEvaluationOptions

The formula evaluation options. / 公式評估選項。

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

OdfFormulaEvaluationReport

The evaluation report. / 評估報告。

Exceptions

ArgumentNullException

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

OdfFormulaEvaluationException

Thrown when strict evaluation fails. / 當嚴格評估失敗時擲出。

OperationCanceledException

Thrown when cancellation is requested. / 當要求取消時擲出。

FindDataValidation(string)

Finds a data validation rule by its exact name. 依精確名稱尋找資料驗證規則。

public OdfDataValidationInfo? FindDataValidation(string name)

Parameters

name string

The exact rule name. / 規則的精確名稱。

Returns

OdfDataValidationInfo

The matching rule summary, or null. / 相符的規則摘要;若不存在則為 null

FindDatabaseRange(string)

Finds an editable database range by its exact name. 依精確名稱尋找可編輯的資料庫範圍。

public OdfDatabaseRange? FindDatabaseRange(string name)

Parameters

name string

The exact name. / 精確名稱。

Returns

OdfDatabaseRange

The matching database range, or null. / 相符的資料庫範圍;若不存在則為 null

FindEmbeddedChart(string)

Finds an embedded chart by its subpackage path. 依子封裝路徑尋找嵌入圖表。

public OdfEmbeddedChartInfo? FindEmbeddedChart(string objectPath)

Parameters

objectPath string

The embedded chart subpackage path. / 嵌入圖表子封裝路徑。

Returns

OdfEmbeddedChartInfo

The chart summary when found; otherwise, null. / 找到時為圖表摘要;否則為 null

FindFrozenPanes(string)

Finds frozen pane settings for a worksheet. 尋找工作表的凍結窗格設定。

public OdfSheetFrozenPanesInfo? FindFrozenPanes(string sheetName)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

Returns

OdfSheetFrozenPanesInfo

The frozen pane summary when configured; otherwise, null. / 已設定時為凍結窗格摘要;否則為 null

FindPivotTable(string)

Finds a pivot table definition by its exact name. 依精確名稱尋找樞紐分析表定義。

public OdfPivotTableInfo? FindPivotTable(string name)

Parameters

name string

The exact name. / 精確名稱。

Returns

OdfPivotTableInfo

The matching definition, or null. / 相符的定義;若不存在則為 null

FindSheet(string)

Finds the worksheet with the specified name. 尋找指定名稱的工作表。

public OdfTableSheet? FindSheet(string name)

Parameters

name string

The name or identifier. / 工作表名稱

Returns

OdfTableSheet

The result. / 找不到則傳回 null

FindSplitPanes(string)

Finds split pane settings for a worksheet. 尋找工作表的分割窗格設定。

public OdfSheetSplitPanesInfo? FindSplitPanes(string sheetName)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

Returns

OdfSheetSplitPanesInfo

The split pane summary when configured; otherwise, null. / 已設定時為分割窗格摘要;否則為 null

FindTable(string)

Finds an editable practical spreadsheet table by name. 依名稱尋找可編輯的實務試算表表格。

public OdfSpreadsheetTable? FindTable(string name)

Parameters

name string

The table name. / 表格名稱。

Returns

OdfSpreadsheetTable

The table facade, or null when not found. / 表格 facade;找不到時為 null

GetConditionalFormats()

Gets summaries for LibreOffice calcext conditional formatting rules across all worksheets in the spreadsheet. 取得試算表中所有工作表的 LibreOffice calcext 條件格式規則摘要清單。

public IReadOnlyList<OdfConditionalFormatInfo> GetConditionalFormats()

Returns

IReadOnlyList<OdfConditionalFormatInfo>

GetDataValidations()

Gets summaries for all data validation rules in the spreadsheet. 取得試算表中所有資料驗證規則的摘要清單。

public IReadOnlyList<OdfDataValidationInfo> GetDataValidations()

Returns

IReadOnlyList<OdfDataValidationInfo>

GetDatabaseRanges()

Gets summaries for all database ranges in the spreadsheet. 取得試算表中所有資料庫範圍的摘要清單。

public IReadOnlyList<OdfDatabaseRangeInfo> GetDatabaseRanges()

Returns

IReadOnlyList<OdfDatabaseRangeInfo>

Gets read-only summaries for all formula DDE links in the spreadsheet. 取得試算表中所有公式 DDE 連結的唯讀摘要清單。

public IReadOnlyList<OdfDdeLinkInfo> GetDdeLinks()

Returns

IReadOnlyList<OdfDdeLinkInfo>

The DDE link summaries in document order. / 依文件順序排列的 DDE 連結摘要。

This method only inspects document markup and cached-table metadata. It never connects to a DDE server or refreshes cached data. 此方法只檢查文件標記與快取表格中繼資料,絕不連線至 DDE 伺服器或更新快取資料。

GetDefaultContentXml()

Gets the default content.xml content. 取得預設的 content.xml 內容。

protected override string GetDefaultContentXml()

Returns

string

The default XML content string. / 預設的 XML 內容字串。

GetDefaultStylesXml()

Gets the default styles.xml content. 取得預設的 styles.xml 內容。

protected override string GetDefaultStylesXml()

Returns

string

The default XML content string. / 預設的 XML 內容字串。

GetEmbeddedChartDocument(OdfEmbeddedChartInfo)

Gets the chart document for an embedded chart subpackage for advanced editing. 取得嵌入圖表的子封裝圖表文件,以供進階編輯。

public OdfChartDocument GetEmbeddedChartDocument(OdfEmbeddedChartInfo chartInfo)

Parameters

chartInfo OdfEmbeddedChartInfo

The embedded chart summary information. / 嵌入圖表摘要資訊。

Returns

OdfChartDocument

The editable OdfChartDocument instance. / 可編輯的 OdfChartDocument 執行個體。

Remarks

傳回的執行個體會從目前封裝中既有的 content.xml 位元組重新解析出獨立的 DOM 樹, 對其呼叫的任何修改方法(例如 ApplyDefinition(OdfChartDefinition)ClearSeries() 等)會先變更此記憶體中的 DOM。 父文件儲存時會自動 flush 已追蹤的嵌入圖表;呼叫端也可手動呼叫傳回執行個體的 Save 方法,以提早將變更寫回共用封裝。

GetEmbeddedChartDocument(string)

Gets an embedded chart document by subpackage path. 依子封裝路徑取得嵌入圖表文件。

public OdfChartDocument GetEmbeddedChartDocument(string objectPath)

Parameters

objectPath string

The embedded chart subpackage path (e.g. Object 1/). / 嵌入圖表子封裝路徑(例如 Object 1/)。

Returns

OdfChartDocument

The editable OdfChartDocument instance. / 可編輯的 OdfChartDocument 執行個體。

Remarks

父文件儲存時會自動 flush 對傳回執行個體所做的修改;呼叫端仍可手動呼叫其 Save 方法,以提早寫回共用封裝。

GetEmbeddedCharts()

Gets summaries for all embedded charts in the spreadsheet. 取得試算表中所有嵌入圖表的摘要清單。

public IReadOnlyList<OdfEmbeddedChartInfo> GetEmbeddedCharts()

Returns

IReadOnlyList<OdfEmbeddedChartInfo>

GetFormula(string, string)

Gets the formula for a cell in the specified worksheet. 取得指定工作表儲存格的公式。

public string GetFormula(string sheetName, string address)

Parameters

sheetName string

The name or identifier. / 工作表名稱

address string

The cell address. / 儲存格位址,例如 A1

Returns

string

The result. / 指定儲存格的公式;若沒有公式則為空字串

GetFormulaCells()

Gets all used cells with formulas in the workbook. 取得活頁簿中所有含公式的已使用儲存格。

public IEnumerable<OdfFormulaCellInfo> GetFormulaCells()

Returns

IEnumerable<OdfFormulaCellInfo>

The result. / 含公式儲存格資訊列舉

GetFormulaCells(Func<OdfFormulaCellInfo, bool>)

Gets formula cells in the workbook that match the specified predicate. 取得活頁簿中符合指定條件的公式儲存格。

public IEnumerable<OdfFormulaCellInfo> GetFormulaCells(Func<OdfFormulaCellInfo, bool> predicate)

Parameters

predicate Func<OdfFormulaCellInfo, bool>

The delegate to invoke. / 用來篩選公式儲存格的條件委派

Returns

IEnumerable<OdfFormulaCellInfo>

The result. / 符合條件的公式儲存格資訊列舉

GetFrozenPanes()

Gets summaries for all worksheets in the spreadsheet that define frozen panes. 取得試算表中所有已設定凍結窗格的工作表摘要清單。

public IReadOnlyList<OdfSheetFrozenPanesInfo> GetFrozenPanes()

Returns

IReadOnlyList<OdfSheetFrozenPanesInfo>

GetNamedExpressions()

Gets summaries for all named expressions in the spreadsheet, including document-level and worksheet-level expressions. 取得試算表中所有具名運算式的摘要清單(含文件層與各工作表層)。

public IReadOnlyList<OdfNamedExpressionInfo> GetNamedExpressions()

Returns

IReadOnlyList<OdfNamedExpressionInfo>

GetNamedRanges()

Gets summaries for all named ranges in the spreadsheet, including document-level and worksheet-level ranges. 取得試算表中所有命名範圍的摘要清單(含文件層與各工作表層)。

public IReadOnlyList<OdfNamedRangeInfo> GetNamedRanges()

Returns

IReadOnlyList<OdfNamedRangeInfo>

GetPivotTables()

Gets summaries for pivot tables across all worksheets in the spreadsheet. 取得試算表中所有工作表的樞紐分析表摘要清單。

public IReadOnlyList<OdfPivotTableInfo> GetPivotTables()

Returns

IReadOnlyList<OdfPivotTableInfo>

GetPrintAreas()

Gets summaries for all worksheets in the spreadsheet that define print areas. 取得試算表中所有已設定列印範圍的工作表摘要清單。

public IReadOnlyList<OdfSheetPrintAreaInfo> GetPrintAreas()

Returns

IReadOnlyList<OdfSheetPrintAreaInfo>

GetSheetReferences(string)

Gets formula cells outside the specified worksheet that reference it. 取得指定工作表之外參照該工作表的公式儲存格。

public IReadOnlyList<OdfFormulaCellInfo> GetSheetReferences(string sheetName)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

Returns

IReadOnlyList<OdfFormulaCellInfo>

The blocking formula references. / 會阻擋移除的公式參照。

GetSheets()

Gets all worksheets in the current workbook. 取得目前活頁簿中所有的工作表。

public IReadOnlyList<OdfTableSheet> GetSheets()

Returns

IReadOnlyList<OdfTableSheet>

The result. / 工作表唯讀清單

GetSparklineGroups()

Gets summaries for LibreOffice calcext sparkline groups across all worksheets in the spreadsheet. 取得試算表中所有工作表的 LibreOffice calcext 走勢圖群組摘要清單。

public IReadOnlyList<OdfSparklineGroupInfo> GetSparklineGroups()

Returns

IReadOnlyList<OdfSparklineGroupInfo>

GetSplitPanes()

Gets summaries for all worksheets in the spreadsheet that define split panes. 取得試算表中所有已設定分割窗格的工作表摘要清單。

public IReadOnlyList<OdfSheetSplitPanesInfo> GetSplitPanes()

Returns

IReadOnlyList<OdfSheetSplitPanesInfo>

GetTables()

Gets practical spreadsheet table summaries. 取得實務試算表表格摘要。

public IReadOnlyList<OdfSpreadsheetTableInfo> GetTables()

Returns

IReadOnlyList<OdfSpreadsheetTableInfo>

The table summaries. / 表格摘要。

GetTrackedChanges()

Gets summaries for all tracked changes in the document. 取得文件中所有追蹤修訂摘要。

public IReadOnlyList<OdfSpreadsheetTrackedChangeInfo> GetTrackedChanges()

Returns

IReadOnlyList<OdfSpreadsheetTrackedChangeInfo>

The list of tracked changes. / 追蹤修訂清單。

GetUsedRange(string)

Gets the used range of the specified worksheet. 取得指定工作表的已使用範圍。

public OdfCellRange? GetUsedRange(string sheetName)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

Returns

OdfCellRange?

The used range, or null when the sheet is empty. / 已使用範圍;工作表為空時傳回 null

ImportRecordsAsync<T>(string, string, IAsyncEnumerable<T>)

Imports asynchronous records into an in-memory worksheet using readable public members. 使用可讀公開成員,將非同步記錄匯入記憶體內的工作表。

public Task<OdfObjectBindingReport> ImportRecordsAsync<T>(string sheetName, string startAddress, IAsyncEnumerable<T> records)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

records IAsyncEnumerable<T>

The asynchronous record source. / 非同步記錄來源。

Returns

Task<OdfObjectBindingReport>

The object binding report. / 物件繫結報告。

Type Parameters

T

The record type. / 記錄型別。

ImportRecordsAsync<T>(string, string, IAsyncEnumerable<T>, OdfObjectBindingOptions?, CancellationToken)

Imports records from an asynchronous source into a worksheet using typed binding options. 從非同步來源匯入記錄至工作表,使用具型別繫結選項。

public Task<OdfObjectBindingReport> ImportRecordsAsync<T>(string sheetName, string startAddress, IAsyncEnumerable<T> records, OdfObjectBindingOptions? options, CancellationToken cancellationToken)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

records IAsyncEnumerable<T>

The asynchronous record source. / 非同步記錄來源。

options OdfObjectBindingOptions

The typed binding options. / 具型別繫結選項。

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

Task<OdfObjectBindingReport>

The object binding report. / 物件繫結報告。

Type Parameters

T

The record type. / 記錄型別。

Exceptions

ArgumentNullException

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

ImportRecordsAsync<T>(string, string, IAsyncEnumerable<T>, CancellationToken)

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

public Task<OdfObjectBindingReport> ImportRecordsAsync<T>(string sheetName, string startAddress, IAsyncEnumerable<T> records, CancellationToken cancellationToken)

Parameters

sheetName string
startAddress string
records IAsyncEnumerable<T>
cancellationToken CancellationToken

Returns

Task<OdfObjectBindingReport>

Type Parameters

T

ImportRecords<T>(string, string, IEnumerable<T>)

Imports records into a worksheet using public readable members. 使用可讀公開成員將記錄匯入工作表。

public OdfObjectBindingReport ImportRecords<T>(string sheetName, string startAddress, IEnumerable<T> records)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

records IEnumerable<T>

The records to import. / 要匯入的記錄。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The record type. / 記錄型別。

ImportRecords<T>(string, string, IEnumerable<T>, OdfObjectBindingOptions?)

Imports records into a worksheet using typed binding options. 使用具型別繫結選項將記錄匯入工作表。

public OdfObjectBindingReport ImportRecords<T>(string sheetName, string startAddress, IEnumerable<T> records, OdfObjectBindingOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

records IEnumerable<T>

The records to import. / 要匯入的記錄。

options OdfObjectBindingOptions

The typed binding options. / 具型別繫結選項。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The record type. / 記錄型別。

InsertChartFromRange(string, OdfCellAddress, OdfCellRange)

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

public OdfChartDocument InsertChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range)

Parameters

sheetName string
anchor OdfCellAddress
range OdfCellRange

Returns

OdfChartDocument

InsertChartFromRange(string, OdfCellAddress, OdfCellRange, OdfEmbeddedChartOptions?)

Inserts an editable embedded chart bound to a worksheet range. 插入繫結至工作表範圍且可繼續編輯的嵌入圖表。

public OdfChartDocument InsertChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfEmbeddedChartOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

anchor OdfCellAddress

The top-left anchor cell. / 左上角錨定儲存格。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

options OdfEmbeddedChartOptions

The embedded chart options. / 嵌入圖表選項。

Returns

OdfChartDocument

The embedded chart document. / 嵌入的圖表文件。

Load(Stream)

Loads an ODS spreadsheet document from the specified stream. 從指定資料流載入 ODS 試算表文件。

public static SpreadsheetDocument Load(Stream stream)

Parameters

stream Stream

Returns

SpreadsheetDocument

The loaded SpreadsheetDocument instance. / 載入完成的 SpreadsheetDocument 執行個體。

Exceptions

InvalidOperationException

When the specified document is not an ODS spreadsheet. / 當指定文件不是 ODS 試算表時擲出。

Load(Stream, string?)

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

public static SpreadsheetDocument Load(Stream stream, string? fileName)

Parameters

stream Stream
fileName string

Returns

SpreadsheetDocument

Load(string)

Loads an ODS spreadsheet document from the specified path. 從指定路徑載入 ODS 試算表文件。

public static SpreadsheetDocument Load(string path)

Parameters

path string

The ODS document path. / ODS 文件路徑。

Returns

SpreadsheetDocument

The loaded SpreadsheetDocument instance. / 載入完成的 SpreadsheetDocument 執行個體。

Exceptions

InvalidOperationException

When the specified document is not an ODS spreadsheet. / 當指定文件不是 ODS 試算表時擲出。

LoadAsync(Stream)

Asynchronously loads an ODS spreadsheet document from the specified stream. 非同步從指定資料流載入 ODS 試算表文件。

public static Task<SpreadsheetDocument> LoadAsync(Stream stream)

Parameters

stream Stream

Returns

Task<SpreadsheetDocument>

A task representing the asynchronous load operation, whose result is the loaded SpreadsheetDocument. / 代表非同步載入作業的工作,其結果為載入完成的 SpreadsheetDocument

LoadAsync(Stream, string?)

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

public static Task<SpreadsheetDocument> LoadAsync(Stream stream, string? fileName)

Parameters

stream Stream
fileName string

Returns

Task<SpreadsheetDocument>

LoadAsync(Stream, string?, CancellationToken)

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

public static Task<SpreadsheetDocument> LoadAsync(Stream stream, string? fileName, CancellationToken cancellationToken)

Parameters

stream Stream
fileName string
cancellationToken CancellationToken

Returns

Task<SpreadsheetDocument>

LoadAsync(Stream, CancellationToken)

Asynchronously loads the document from a stream with a cancellation token. 以取消語彙基元非同步從資料流載入文件。

public static Task<SpreadsheetDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)

Parameters

stream Stream

The document stream. / 文件資料流。

cancellationToken CancellationToken

The cancellation token. / 取消語彙基元。

Returns

Task<SpreadsheetDocument>

A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的文件。

LoadAsync(string)

Asynchronously loads an ODS spreadsheet document from the specified path. 非同步從指定路徑載入 ODS 試算表文件。

public static Task<SpreadsheetDocument> LoadAsync(string path)

Parameters

path string

Returns

Task<SpreadsheetDocument>

A task representing the asynchronous load operation, whose result is the loaded SpreadsheetDocument. / 代表非同步載入作業的工作,其結果為載入完成的 SpreadsheetDocument

Remarks

若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與封裝初始化期間協作檢查取消語彙。

LoadAsync(string, CancellationToken)

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

public static Task<SpreadsheetDocument> LoadAsync(string path, CancellationToken cancellationToken)

Parameters

path string
cancellationToken CancellationToken

Returns

Task<SpreadsheetDocument>

MergeContentNodes(OdfDocument, OdfMergeOptions, Dictionary<string, string>)

Merges content nodes from the source document. 合併來源文件的內容節點。

protected override void MergeContentNodes(OdfDocument sourceDoc, OdfMergeOptions options, Dictionary<string, string> renameMap)

Parameters

sourceDoc OdfDocument

The value to use. / 來源文件

options OdfMergeOptions

The value to use. / 合併選項

renameMap Dictionary<string, string>

The name or identifier. / 重命名對照表

Exceptions

ArgumentException

Thrown when the documented condition occurs. / 當來源文件類型不正確時擲出

ProtectWorkbook(string)

Enables workbook protection and stores the hashed protection password. 啟用活頁簿保護,並設定雜湊後的保護密碼。

public void ProtectWorkbook(string password)

Parameters

password string

The password text. / 密碼明文

ReadObjects<T>(string, OdfCellRange)

Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。

public IReadOnlyList<T> ReadObjects<T>(string sheetName, OdfCellRange range) where T : new()

Parameters

sheetName string
range OdfCellRange

Returns

IReadOnlyList<T>

Type Parameters

T

ReadObjects<T>(string, OdfCellRange, OdfObjectReadOptions?)

Reads rows from the specified worksheet into objects using the header row as the property map. 使用標題列作為屬性對應,將指定工作表資料列讀成物件。

public IReadOnlyList<T> ReadObjects<T>(string sheetName, OdfCellRange range, OdfObjectReadOptions? options) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

options OdfObjectReadOptions

The object read options. / 物件讀取選項。

Returns

IReadOnlyList<T>

The materialized object list. / 具體化後的物件清單。

Type Parameters

T

The object type to create. / 要建立的物件型別。

ReadRecordsAsync<T>(string, string)

Reads an A1 worksheet range into an asynchronous record sequence. 將 A1 工作表範圍讀取為非同步記錄序列。

public IAsyncEnumerable<T> ReadRecordsAsync<T>(string sheetName, string range) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range string

The A1 source range. / A1 來源範圍。

Returns

IAsyncEnumerable<T>

The materialized records, yielded asynchronously. / 具體化後的記錄,以非同步方式產生。

Type Parameters

T

The record type. / 記錄型別。

ReadRecordsAsync<T>(string, string, OdfObjectReadOptions?, CancellationToken)

Reads worksheet rows into records asynchronously using typed read options. 使用具型別讀取選項非同步將工作表資料列讀成記錄。

public IAsyncEnumerable<T> ReadRecordsAsync<T>(string sheetName, string range, OdfObjectReadOptions? options, CancellationToken cancellationToken) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range string

The A1 source range. / A1 來源範圍。

options OdfObjectReadOptions

The typed read options. / 具型別讀取選項。

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

IAsyncEnumerable<T>

The materialized records, yielded asynchronously. / 具體化後的記錄,以非同步方式產生。

Type Parameters

T

The record type. / 記錄型別。

ReadRecordsAsync<T>(string, string, CancellationToken)

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

public IAsyncEnumerable<T> ReadRecordsAsync<T>(string sheetName, string range, CancellationToken cancellationToken) where T : new()

Parameters

sheetName string
range string
cancellationToken CancellationToken

Returns

IAsyncEnumerable<T>

Type Parameters

T

ReadRecords<T>(string, string)

Reads worksheet rows into records using an A1 range. 使用 A1 範圍將工作表資料列讀成記錄。

public IReadOnlyList<T> ReadRecords<T>(string sheetName, string range) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range string

The A1 source range. / A1 來源範圍。

Returns

IReadOnlyList<T>

The materialized records. / 具體化後的記錄。

Type Parameters

T

The record type. / 記錄型別。

ReadRecords<T>(string, string, OdfObjectReadOptions?)

Reads worksheet rows into records using typed read options. 使用具型別讀取選項將工作表資料列讀成記錄。

public IReadOnlyList<T> ReadRecords<T>(string sheetName, string range, OdfObjectReadOptions? options) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range string

The A1 source range. / A1 來源範圍。

options OdfObjectReadOptions

The typed read options. / 具型別讀取選項。

Returns

IReadOnlyList<T>

The materialized records. / 具體化後的記錄。

Type Parameters

T

The record type. / 記錄型別。

RefreshChartDataRange(OdfChartDocument, string, OdfCellRange)

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

public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range)

Parameters

chart OdfChartDocument
sheetName string
range OdfCellRange

Returns

OdfChartDocument

RefreshChartDataRange(OdfChartDocument, string, OdfCellRange, bool)

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

public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range, bool firstRowAsHeader)

Parameters

chart OdfChartDocument
sheetName string
range OdfCellRange
firstRowAsHeader bool

Returns

OdfChartDocument

RefreshChartDataRange(OdfChartDocument, string, OdfCellRange, bool, bool)

Refreshes an embedded chart data range. 重新設定嵌入圖表的資料範圍。

public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range, bool firstRowAsHeader, bool firstColumnAsLabel)

Parameters

chart OdfChartDocument

The embedded chart document. / 嵌入圖表文件。

sheetName string

The worksheet name. / 工作表名稱。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

firstRowAsHeader bool

Whether the first row is treated as series labels. / 首列是否視為序列標籤。

firstColumnAsLabel bool

Whether the first column is treated as category labels. / 首欄是否視為分類標籤。

Returns

OdfChartDocument

The updated embedded chart document. / 已更新的嵌入圖表文件。

RefreshPivotTable(string)

Refreshes a persisted pivot table with default resource limits. 使用預設資源限制刷新已持久化的樞紐分析表。

public OdfPivotRefreshResult RefreshPivotTable(string name)

Parameters

name string

The exact pivot table name. / 樞紐分析表的精確名稱。

Returns

OdfPivotRefreshResult

The refresh report. / 刷新報告。

RefreshPivotTable(string, OdfPivotRefreshOptions?, CancellationToken)

Refreshes a persisted pivot table with bounded resource use. 以有界資源使用刷新已持久化的樞紐分析表。

public OdfPivotRefreshResult RefreshPivotTable(string name, OdfPivotRefreshOptions? options, CancellationToken cancellationToken)

Parameters

name string

The exact pivot table name. / 樞紐分析表的精確名稱。

options OdfPivotRefreshOptions

The resource limits, or null for defaults. / 資源限制;null 表示預設值。

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

OdfPivotRefreshResult

The refresh report. / 刷新報告。

RejectAllChanges()

Rejects all pending tracked changes. 拒絕所有待處理的追蹤修訂。

public void RejectAllChanges()

RejectChange(string)

Rejects the specified tracked change. 拒絕指定的追蹤修訂。

public void RejectChange(string changeId)

Parameters

changeId string

The change identifier. / 修訂識別碼。

RemoveDataValidation(string)

Removes a data validation rule and detaches it from every referencing cell. 移除資料驗證規則,並解除所有引用儲存格的關聯。

public bool RemoveDataValidation(string name)

Parameters

name string

The exact rule name. / 規則的精確名稱。

Returns

bool

true if removed; otherwise false. / 若已移除則為 true,否則為 false

RemoveDatabaseRange(OdfDatabaseRange)

Removes the specified database range when it belongs to this document. 在指定資料庫範圍屬於此文件時將其移除。

public bool RemoveDatabaseRange(OdfDatabaseRange range)

Parameters

range OdfDatabaseRange

The database range facade. / 資料庫範圍 facade。

Returns

bool

true if removed; otherwise false. / 若已移除則為 true,否則為 false

RemoveDatabaseRange(string)

Removes a database range by its exact name without removing a same-named range expression. 依精確名稱移除資料庫範圍,但不移除同名的命名範圍運算式。

public bool RemoveDatabaseRange(string name)

Parameters

name string

The exact name. / 精確名稱。

Returns

bool

true if removed; otherwise false. / 若已移除則為 true,否則為 false

RemoveEmbeddedChart(OdfEmbeddedChartInfo)

Removes an embedded chart and its package subdocument. 移除嵌入圖表及其封裝子文件。

public bool RemoveEmbeddedChart(OdfEmbeddedChartInfo chartInfo)

Parameters

chartInfo OdfEmbeddedChartInfo

The embedded chart summary to remove. / 要移除的嵌入圖表摘要。

Returns

bool

true if the chart was removed; otherwise, false. / 若已移除圖表則為 true;否則為 false

RemoveEmbeddedChart(string)

Removes an embedded chart by subpackage path and cleans all package relations. 依子封裝路徑移除嵌入圖表,並清理所有封裝關聯。

public bool RemoveEmbeddedChart(string objectPath)

Parameters

objectPath string

The embedded chart subpackage path. / 嵌入圖表子封裝路徑。

Returns

bool

true if the chart was removed; otherwise, false. / 若已移除圖表則為 true;否則為 false

RemovePivotTable(string)

Removes a pivot table definition without clearing cached worksheet output cells. 移除樞紐分析表定義,但不清除工作表中的快取輸出儲存格。

public bool RemovePivotTable(string name)

Parameters

name string

The exact name. / 精確名稱。

Returns

bool

true if removed; otherwise false. / 若已移除則為 true,否則為 false

RemoveSheet(OdfTableSheet)

Removes a worksheet when no formula outside it references the worksheet. 當沒有外部公式參照時移除工作表。

public bool RemoveSheet(OdfTableSheet sheet)

Parameters

sheet OdfTableSheet

The worksheet to remove. / 要移除的工作表。

Returns

bool

true if the worksheet was removed; otherwise, false. / 若已移除工作表則為 true;否則為 false

ReplaceFormulaText(string, string)

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

public int ReplaceFormulaText(string oldValue, string newValue)

Parameters

oldValue string
newValue string

Returns

int

ReplaceFormulaText(string, string, StringComparison)

Replaces the specified text in all formulas in the workbook. 取代活頁簿所有公式中的指定文字。

public int ReplaceFormulaText(string oldValue, string newValue, StringComparison comparisonType)

Parameters

oldValue string

The value to use. / 要尋找的文字

newValue string

The value to use. / 替換後的文字

comparisonType StringComparison

The value to use. / 文字比對方式

Returns

int

The result. / 實際變更的公式數量

ResizeTable(string, OdfCellRange)

Resizes a practical spreadsheet table by name. 依名稱調整實務試算表表格範圍。

public bool ResizeTable(string name, OdfCellRange range)

Parameters

name string

The table name. / 表格名稱。

range OdfCellRange

The new cell range. / 新儲存格範圍。

Returns

bool

true if updated; otherwise false. / 若已更新則為 true;否則為 false

SetFormula(string, string, string)

Sets the formula for a cell in the specified worksheet. 設定指定工作表儲存格的公式。

public OdfCell SetFormula(string sheetName, string address, string formula)

Parameters

sheetName string

The name or identifier. / 工作表名稱

address string

The cell address. / 儲存格位址,例如 A1

formula string

The value to use. / 要寫入的公式;傳入空字串會清除公式

Returns

OdfCell

The result. / 已更新的儲存格 facade

SetFormula(string, string, string, object?)

Sets the formula and cached value for a cell in the specified worksheet. 設定指定工作表儲存格的公式與快取值。

public OdfCell SetFormula(string sheetName, string address, string formula, object? cachedValue)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

address string

The cell address. / 儲存格位址,例如 A1

formula string

The ODF formula text; an empty value clears the formula. / ODF 公式文字;空值會清除公式。

cachedValue object

The cached value stored with the formula. / 隨公式儲存的快取值。

Returns

OdfCell

The updated cell facade. / 已更新的儲存格 facade。

SetRangeValues(string, string, object?[,])

Sets a rectangular value block using a worksheet name and A1 start address. 使用工作表名稱與 A1 起始位址設定矩形資料區塊。

public OdfRangeWriteReport SetRangeValues(string sheetName, string startAddress, object?[,] values)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

values object[,]

The rectangular values. / 矩形資料值。

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

SetRangeValues(string, string, object?[,], OdfRangeWriteOptions?)

Sets a rectangular value block using typed write options. 使用具型別寫入選項設定矩形資料區塊。

public OdfRangeWriteReport SetRangeValues(string sheetName, string startAddress, object?[,] values, OdfRangeWriteOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress string

The top-left A1 address. / 左上角 A1 位址。

values object[,]

The rectangular values. / 矩形資料值。

options OdfRangeWriteOptions

The typed range write options. / 具型別範圍寫入選項。

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

SetValue(string, string, object?)

Sets one cell value using a worksheet name and A1 address. 使用工作表名稱與 A1 位址設定單一儲存格值。

public OdfRangeWriteReport SetValue(string sheetName, string address, object? value)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

address string

The A1 cell address. / A1 儲存格位址。

value object

The value to write. / 要寫入的值。

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

SetValues(string, OdfCellAddress, IEnumerable<IEnumerable<object?>>)

Sets rows of values in the specified worksheet. 在指定工作表逐列設定資料。

public OdfCellRange SetValues(string sheetName, OdfCellAddress startAddress, IEnumerable<IEnumerable<object?>> rows)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress OdfCellAddress

The top-left target cell. / 左上角目標儲存格。

rows IEnumerable<IEnumerable<object>>

The row values to write. / 要寫入的資料列。

Returns

OdfCellRange

The updated range. / 已更新的範圍。

SetValues(string, OdfCellAddress, IEnumerable<IEnumerable<object?>>, OdfRangeWriteOptions?)

Sets rows of values in the specified worksheet and returns a write report. 在指定工作表逐列設定資料並傳回寫入報告。

public OdfRangeWriteReport SetValues(string sheetName, OdfCellAddress startAddress, IEnumerable<IEnumerable<object?>> rows, OdfRangeWriteOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress OdfCellAddress

The top-left target cell. / 左上角目標儲存格。

rows IEnumerable<IEnumerable<object>>

The row values to write. / 要寫入的資料列。

options OdfRangeWriteOptions

The range write options. / 範圍寫入選項。

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

SetValues(string, OdfCellAddress, object?[,])

Sets a rectangular block of values in the specified worksheet. 在指定工作表設定一個矩形資料區塊。

public OdfCellRange SetValues(string sheetName, OdfCellAddress startAddress, object?[,] values)

Parameters

sheetName string
startAddress OdfCellAddress
values object[,]

Returns

OdfCellRange

The updated range. / 已更新的範圍。

SetValues(string, OdfCellAddress, object?[,], OdfRangeWriteOptions?)

Sets a rectangular block of values in the specified worksheet and returns a write report. 在指定工作表設定矩形資料區塊並傳回寫入報告。

public OdfRangeWriteReport SetValues(string sheetName, OdfCellAddress startAddress, object?[,] values, OdfRangeWriteOptions? options)

Parameters

sheetName string
startAddress OdfCellAddress
values object[,]
options OdfRangeWriteOptions

Returns

OdfRangeWriteReport

The range write report. / 範圍寫入報告。

TryGetFormula(string, string, out string)

Attempts to get the formula for a cell in the specified worksheet. 嘗試取得指定工作表儲存格的公式。

public bool TryGetFormula(string sheetName, string address, out string formula)

Parameters

sheetName string

The name or identifier. / 工作表名稱

address string

The cell address. / 儲存格位址,例如 A1

formula string

The value to use. / 取得成功時傳回公式文字

Returns

bool

The result. / 若指定儲存格具有公式則為 true,否則為 false

TryRemoveSheet(string, out IReadOnlyList<OdfFormulaCellInfo>)

Attempts to remove a worksheet without leaving formula references dangling. 嘗試移除工作表,且不留下懸空的公式參照。

public bool TryRemoveSheet(string sheetName, out IReadOnlyList<OdfFormulaCellInfo> blockingReferences)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

blockingReferences IReadOnlyList<OdfFormulaCellInfo>

Formula cells that prevented removal. / 阻擋移除的公式儲存格。

Returns

bool

true if the worksheet was removed; otherwise, false. / 若已移除工作表則為 true;否則為 false

UpdateDataValidation(string, string, OdfDataValidation)

Updates a data validation rule in place and reapplies it to the requested worksheet range. 就地更新資料驗證規則,並將其重新套用至指定工作表範圍。

public bool UpdateDataValidation(string name, string sheetName, OdfDataValidation validation)

Parameters

name string

The exact existing rule name. / 既有規則的精確名稱。

sheetName string

The target worksheet name. / 目標工作表名稱。

validation OdfDataValidation

The replacement definition and range. / 取代用定義與範圍。

Returns

bool

true if updated; otherwise false. / 若已更新則為 true,否則為 false

UpdateEmbeddedChartSeries(OdfChartDocument, IEnumerable<OdfEmbeddedChartSeriesUpdate>)

Applies practical updates to embedded chart series. 將實務更新套用至嵌入圖表序列。

public OdfBatchUpdateResult UpdateEmbeddedChartSeries(OdfChartDocument chart, IEnumerable<OdfEmbeddedChartSeriesUpdate> updates)

Parameters

chart OdfChartDocument

The embedded chart document. / 嵌入圖表文件。

updates IEnumerable<OdfEmbeddedChartSeriesUpdate>

The series updates. / 序列更新。

Returns

OdfBatchUpdateResult

The batch update result. / 批次更新結果。

UpdateFormulas(Func<OdfFormulaCellInfo, string?>)

Updates all formulas in the workbook. 更新活頁簿中的所有公式。

public int UpdateFormulas(Func<OdfFormulaCellInfo, string?> updater)

Parameters

updater Func<OdfFormulaCellInfo, string>

The delegate to invoke. / 接收目前公式資訊並傳回新公式的委派;傳回 null 表示不變更

Returns

int

The result. / 實際變更的公式數量

UpdateObjects<T>(string, OdfCellRange, IEnumerable<T>, OdfObjectUpdateOptions)

Updates existing object-bound rows by key without inserting new rows. 依 key 更新既有物件繫結資料列且不新增資料列。

public OdfObjectBindingReport UpdateObjects<T>(string sheetName, OdfCellRange range, IEnumerable<T> items, OdfObjectUpdateOptions options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range OdfCellRange

The target table range. / 目標資料表範圍。

items IEnumerable<T>

The object sequence to update. / 要更新的物件序列。

options OdfObjectUpdateOptions

The update options. / 更新選項。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The object type to update. / 要更新的物件型別。

UpdatePivotTableRanges(string, OdfCellRange, OdfCellRange)

Updates the source and target ranges of a pivot table definition without recalculating its output. 更新樞紐分析表定義的來源與目標範圍,但不重新計算其輸出。

public bool UpdatePivotTableRanges(string name, OdfCellRange sourceRange, OdfCellRange targetRange)

Parameters

name string

The exact name. / 精確名稱。

sourceRange OdfCellRange

The replacement source range. / 取代用來源範圍。

targetRange OdfCellRange

The replacement target range. / 取代用目標範圍。

Returns

bool

true if updated; otherwise false. / 若已更新則為 true,否則為 false

UpsertObjects<T>(string, OdfCellRange, IEnumerable<T>, OdfObjectUpdateOptions)

Updates object-bound rows by key and inserts rows for missing keys. 依 key 更新物件繫結資料列,並針對缺少的 key 新增資料列。

public OdfObjectBindingReport UpsertObjects<T>(string sheetName, OdfCellRange range, IEnumerable<T> items, OdfObjectUpdateOptions options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range OdfCellRange

The target table range. / 目標資料表範圍。

items IEnumerable<T>

The object sequence to upsert. / 要 upsert 的物件序列。

options OdfObjectUpdateOptions

The update options. / 更新選項。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The object type to upsert. / 要 upsert 的物件型別。

ValidateObjectBinding<T>(string, OdfCellRange)

Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。

public OdfObjectBindingValidationReport ValidateObjectBinding<T>(string sheetName, OdfCellRange range) where T : new()

Parameters

sheetName string
range OdfCellRange

Returns

OdfObjectBindingValidationReport

Type Parameters

T

ValidateObjectBinding<T>(string, OdfCellRange, OdfObjectReadOptions?)

Validates whether a worksheet range can be bound to the specified object type. 驗證工作表範圍是否可繫結至指定物件型別。

public OdfObjectBindingValidationReport ValidateObjectBinding<T>(string sheetName, OdfCellRange range, OdfObjectReadOptions? options) where T : new()

Parameters

sheetName string

The worksheet name. / 工作表名稱。

range OdfCellRange

The source cell range. / 來源儲存格範圍。

options OdfObjectReadOptions

The validation options. / 驗證選項。

Returns

OdfObjectBindingValidationReport

The validation report. / 驗證報告。

Type Parameters

T

The object type to validate. / 要驗證的物件型別。

VerifyWorkbookPassword(string)

Verifies whether the specified workbook password is valid. 驗證指定的活頁簿密碼是否正確。

public bool VerifyWorkbookPassword(string password)

Parameters

password string

The password text. / 要驗證的密碼

Returns

bool

The result. / 若驗證成功則為 true,否則為 false

WriteObjects<T>(string, OdfCellAddress, IEnumerable<T>)

Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。

public OdfObjectBindingReport WriteObjects<T>(string sheetName, OdfCellAddress startAddress, IEnumerable<T> items)

Parameters

sheetName string
startAddress OdfCellAddress
items IEnumerable<T>

Returns

OdfObjectBindingReport

Type Parameters

T

WriteObjects<T>(string, OdfCellAddress, IEnumerable<T>, OdfObjectBindingOptions?)

Writes public readable object properties into the specified worksheet. 將物件的可讀公開屬性寫入指定工作表。

public OdfObjectBindingReport WriteObjects<T>(string sheetName, OdfCellAddress startAddress, IEnumerable<T> items, OdfObjectBindingOptions? options)

Parameters

sheetName string

The worksheet name. / 工作表名稱。

startAddress OdfCellAddress

The top-left target cell. / 左上角目標儲存格。

items IEnumerable<T>

The object sequence to write. / 要寫入的物件序列。

options OdfObjectBindingOptions

The object binding options. / 物件繫結選項。

Returns

OdfObjectBindingReport

The object binding report. / 物件繫結報告。

Type Parameters

T

The object type to write. / 要寫入的物件型別。