目錄 / Table of Contents

Class DefaultFormulaEvaluator

Namespace
OdfKit.Formula
Assembly
OdfKit.dll

Evaluates parsed ODF formulas with the default spreadsheet function set. 提供預設的 ODF 公式評估器實作。

public class DefaultFormulaEvaluator : IOdfFormulaEvaluator
Inheritance
DefaultFormulaEvaluator
Implements
Inherited Members

Constructors

DefaultFormulaEvaluator()

Initializes an evaluator with an empty application-defined function registry. 使用空白的應用程式自訂函式註冊表初始化評估器。

public DefaultFormulaEvaluator()

DefaultFormulaEvaluator(OdfFormulaFunctionRegistry)

Initializes an evaluator with application-defined functions. 使用應用程式自訂函式初始化評估器。

public DefaultFormulaEvaluator(OdfFormulaFunctionRegistry functions)

Parameters

functions OdfFormulaFunctionRegistry

The instance-scoped function registry. / 執行個體範圍的函式註冊表。

DefaultFormulaEvaluator(OdfFormulaFunctionRegistry, IOdfFormulaEvaluationFallback?)

Initializes an evaluator with application-defined functions and an unsupported-formula fallback. 使用應用程式自訂函式與不受支援公式的後援初始化評估器。

public DefaultFormulaEvaluator(OdfFormulaFunctionRegistry functions, IOdfFormulaEvaluationFallback? fallback)

Parameters

functions OdfFormulaFunctionRegistry

The instance-scoped function registry. / 執行個體範圍的函式註冊表。

fallback IOdfFormulaEvaluationFallback

The unsupported-formula fallback, or null. / 不受支援公式的後援,或為 null

Properties

Fallback

Gets the fallback used when the in-process evaluator returns an unsupported-name error. 取得處理程序內評估器傳回不受支援名稱錯誤時使用的後援。

public IOdfFormulaEvaluationFallback? Fallback { get; }

Property Value

IOdfFormulaEvaluationFallback

Functions

Gets the instance-scoped application-defined function registry. 取得執行個體範圍的應用程式自訂函式註冊表。

public OdfFormulaFunctionRegistry Functions { get; }

Property Value

OdfFormulaFunctionRegistry

Methods

ClearCache()

Clears the evaluation cache and circular-dependency tracking stack. 清除評估快取與循環相依性追蹤堆疊。

public void ClearCache()

Evaluate(string, IEvaluationContext)

Evaluates a formula string and returns the result. 評估公式字串並傳回結果。

public object Evaluate(string formula, IEvaluationContext context)

Parameters

formula string

The formula string. / 公式字串。

context IEvaluationContext

The evaluation context. / 評估內容模型。

Returns

object

The formula calculation result. / 公式計算後的結果。

Remarks

Parsed syntax trees are cached by formula text, so repeated evaluation of the same formula skips tokenizing and parsing. 剖析後的語法樹會以公式字串為鍵快取,重複評估相同公式時可略過語彙分析與剖析階段。

EvaluateCell(OdfCellAddress, IEvaluationContext)

Evaluates the formula for a specific cell with circular-reference checks and caching. 評估特定儲存格的公式,並使用循環參照檢查與快取機制。

public object EvaluateCell(OdfCellAddress cellAddress, IEvaluationContext context)

Parameters

cellAddress OdfCellAddress

The cell address. / 儲存格位址。

context IEvaluationContext

The evaluation context. / 評估內容模型。

Returns

object

The evaluated cell value. / 評估後的儲存格值。

EvaluateFormulasInDocument(OdfNode)

Evaluates all document formulas under the specified content root and updates their display text and attributes. 評估指定內容根節點下的所有文件公式,並更新其顯示文字與屬性。

public OdfFormulaEvaluationReport EvaluateFormulasInDocument(OdfNode contentRoot)

Parameters

contentRoot OdfNode

The document content root node. / 文件的內容根節點。

Returns

OdfFormulaEvaluationReport

EvaluateFormulasInDocument(OdfNode, OdfExternalLinkManager?)

Evaluates all document formulas under the specified content root and resolves cross-document references through an external link manager. 評估指定內容根節點下的所有文件公式,並使用外部連結管理器解析跨文件參照。

public OdfFormulaEvaluationReport EvaluateFormulasInDocument(OdfNode contentRoot, OdfExternalLinkManager? externalLinks)

Parameters

contentRoot OdfNode

The document content root node. / 文件的內容根節點。

externalLinks OdfExternalLinkManager

The external link manager. / 外部連結管理器。

Returns

OdfFormulaEvaluationReport

EvaluateFormulasInDocument(OdfNode, OdfExternalLinkManager?, OdfFormulaEvaluationOptions, CancellationToken)

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

public OdfFormulaEvaluationReport EvaluateFormulasInDocument(OdfNode contentRoot, OdfExternalLinkManager? externalLinks, OdfFormulaEvaluationOptions options, CancellationToken cancellationToken)

Parameters

contentRoot OdfNode

The document content root. / 文件內容根節點。

externalLinks OdfExternalLinkManager

The external link manager, or null. / 外部連結管理器,或為 null。

options OdfFormulaEvaluationOptions

The evaluation options. / 評估選項。

cancellationToken CancellationToken

The cancellation token. / 取消權杖。

Returns

OdfFormulaEvaluationReport

The evaluation report. / 評估報告。

Exceptions

OdfFormulaEvaluationException

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

OperationCanceledException

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