Table of Contents

Class OdfCell

Namespace
OdfKit.Spreadsheet
Assembly
OdfKit.dll

Represents a cell in an ODF spreadsheet. 表示 ODF 工作表中的一個儲存格。

public class OdfCell
Inheritance
OdfCell
Inherited Members

Remarks

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

Constructors

OdfCell(OdfNode, int, int, SpreadsheetDocument, string)

Represents a cell in an ODF spreadsheet. 表示 ODF 工作表中的一個儲存格。

public OdfCell(OdfNode node, int row, int col, SpreadsheetDocument doc, string sheetName = "")

Parameters

node OdfNode

The cell XML node. / 儲存格 XML 節點。

row int

The zero-based row index. / 採 0 為基準的列索引。

col int

The zero-based column index. / 採 0 為基準的欄索引。

doc SpreadsheetDocument

The spreadsheet document. / 試算表文件。

sheetName string

The containing sheet name. / 所在工作表名稱。

Remarks

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

Properties

CellValue

Gets or sets the commonly typed cell value. 取得或設定儲存格的常用型別值。

public object? CellValue { get; set; }

Property Value

object

Column

Gets the zero-based column index. 取得以 0 為基準的欄索引。

public int Column { get; }

Property Value

int

DisplayText

Gets or sets the displayed text content of the cell as plain text from text:p child nodes. 取得或設定儲存格顯示的文字內容(text:p 子節點的純文字)。

public string DisplayText { get; set; }

Property Value

string

FormattedValue

Gets the display value formatted by the applied number format style, or DisplayText when no style definition exists. 取得依套用數字格式樣式格式化後的顯示值;若無樣式定義則回傳 DisplayText

public string FormattedValue { get; }

Property Value

string

Formula

Gets or sets the cell formula. 取得或設定儲存格的公式。

public string Formula { get; set; }

Property Value

string

RawValue

Gets or sets the raw numeric cell value as the office:value attribute string. 取得或設定儲存格的原始數值(office:value 屬性,字串格式)。

public string RawValue { get; set; }

Property Value

string

RichText

Gets the fluent rich text builder for this cell. 取得此儲存格的富文字鏈式建構器。

public OdfCellRichTextBuilder RichText { get; }

Property Value

OdfCellRichTextBuilder

Row

Gets the zero-based row index. 取得以 0 為基準的列索引。

public int Row { get; }

Property Value

int

Style

Gets the high-level style configuration facade for this cell. 取得此儲存格的高階樣式設定代理 Facade。

public OdfCellStyleProxy Style { get; }

Property Value

OdfCellStyleProxy

StyleName

Gets or sets the table style name applied to the cell. 取得或設定儲存格套用的表格樣式名稱。

public string? StyleName { get; set; }

Property Value

string

ValueType

Gets or sets the type of the cell data value. 取得或設定儲存格資料值的型態。

public string ValueType { get; set; }

Property Value

string

Methods

AddConditionalFormatMap(string, string)

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

public void AddConditionalFormatMap(string condition, string applyStyleName)

Parameters

condition string
applyStyleName string

AddConditionalFormatMap(string, string, OdfCellAddress?)

Adds a conditional formatting map rule. 新增條件格式對應規則。

public void AddConditionalFormatMap(string condition, string applyStyleName, OdfCellAddress? baseCell)

Parameters

condition string

The condition value, such as cell-content()=1. / 條件值,例如 cell-content()=1

applyStyleName string

The formatting style name to apply. / 要套用的格式樣式名稱。

baseCell OdfCellAddress?

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

AppendHtml(string)

Parses and appends an HTML inline rich text fragment to the end of the cell text. 在儲存格文字結尾解析並追加 HTML 行內富文字片段。

public OdfCell AppendHtml(string html)

Parameters

html string

The HTML inline fragment to parse. / 要解析的 HTML 行內片段。

Returns

OdfCell

The current cell for chaining. / 目前儲存格,方便鏈式呼叫。

AppendMarkdown(string)

Parses and appends a Markdown inline rich text fragment to the end of the cell text. 在儲存格文字結尾解析並追加 Markdown 行內富文字片段。

public OdfCell AppendMarkdown(string markdown)

Parameters

markdown string

The Markdown inline text to parse. / 要解析的 Markdown 行內文字。

Returns

OdfCell

The current cell for chaining. / 目前儲存格,方便鏈式呼叫。

FindAnnotation()

Finds the cell annotation, or null when no annotation exists. 尋找儲存格的批注;若無批注則回傳 null。

public OdfCellAnnotation? FindAnnotation()

Returns

OdfCellAnnotation

GetHyperlinkUrl()

Gets the hyperlink URL of the cell, or null when no hyperlink exists. 取得儲存格的超連結 URL;若無超連結則回傳 null。

public string? GetHyperlinkUrl()

Returns

string

GetRichText()

Gets the rich text content of the cell, or null when it is plain text or empty. 取得儲存格的富文字內容;若為純文字或空白則回傳 null。

public OdfRichText? GetRichText()

Returns

OdfRichText

GetValue<T>()

Gets the cell value as the specified type T, returning the default value when conversion fails. 以指定型別 T 取得儲存格值;轉換失敗時回傳預設值。

public T? GetValue<T>()

Returns

T

The converted cell value, or the default value when conversion fails. / 轉換後的儲存格值;轉換失敗時為預設值。

Type Parameters

T

The target value type. / 目標值型別。

RemoveAnnotation()

Removes the cell annotation. 移除儲存格的批注。

public bool RemoveAnnotation()

Returns

bool

true if at least one annotation was removed; otherwise, false. / 若已移除至少一個批注則為 true;否則為 false

Removes the hyperlink of the cell while preserving display text. 移除儲存格的超連結,保留顯示文字。

public bool RemoveHyperlink()

Returns

bool

true if a hyperlink was removed; otherwise, false. / 若已移除超連結則為 true;否則為 false

SetAnnotation(string)

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

public void SetAnnotation(string text)

Parameters

text string

SetAnnotation(string, string?)

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

public void SetAnnotation(string text, string? author)

Parameters

text string
author string

SetAnnotation(string, string?, bool)

Sets the cell annotation and overwrites any existing annotation. 設定儲存格的批注。若已有批注則覆蓋。

public void SetAnnotation(string text, string? author, bool visible)

Parameters

text string

The annotation content. / 批注內容。

author string

The author name. / 作者名稱。

visible bool

Whether to display the annotation; the default is false. / 是否顯示;預設為 false

SetBorders(OdfBorder?, OdfBorder?, OdfBorder?, OdfBorder?)

Sets the border style for all four sides of this cell. 設定此儲存格的四面框線樣式。

public void SetBorders(OdfBorder? top, OdfBorder? bottom, OdfBorder? left, OdfBorder? right)

Parameters

top OdfBorder?

The top border. / 上框線。

bottom OdfBorder?

The bottom border. / 下框線。

left OdfBorder?

The left border. / 左框線。

right OdfBorder?

The right border. / 右框線。

SetFormula(string, object?)

Sets this cell's formula and cached display value. 設定此儲存格的公式與快取顯示值。

public void SetFormula(string formula, object? cachedValue)

Parameters

formula string

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

cachedValue object

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

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

public void SetHyperlink(string url)

Parameters

url string

Sets the hyperlink of the cell. 設定儲存格的超連結。

public void SetHyperlink(string url, string? displayText)

Parameters

url string

The hyperlink URL. / 超連結 URL。

displayText string

The link display text; when null, the existing text content or URL itself is used. / 連結顯示文字;為 null 時使用現有文字內容或 URL 本身。

SetRichText(OdfRichText)

Sets the rich text content of the cell and replaces existing text. 設定儲存格的富文字內容,取代現有文字。

public void SetRichText(OdfRichText richText)

Parameters

richText OdfRichText

The rich text content to write to the cell. / 要寫入儲存格的富文字內容。

SetText(string, OdfTextFontFallbackOptions)

Sets text with the specified font fallback options. 使用指定的字型遞補選項設定文字。

public void SetText(string text, OdfTextFontFallbackOptions options)

Parameters

text string

The text content to write. / 要寫入的文字內容。

options OdfTextFontFallbackOptions

The font fallback options. / 字型遞補選項。

SetValue(bool)

Sets the Boolean value of the cell. 設定儲存格的布林值。

public void SetValue(bool val)

Parameters

val bool

The Boolean value. / 布林值。

SetValue(DateTime)

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

public void SetValue(DateTime date)

Parameters

date DateTime

SetValue(DateTime, bool)

Sets the date and time value of the cell. 設定儲存格的日期時間值。

public void SetValue(DateTime date, bool useTimezoneNaive)

Parameters

date DateTime

The date and time value. / 日期時間。

useTimezoneNaive bool

Whether to ignore time zone conversion and use local time formatting. / 是否忽略時區轉換,使用本地時間格式。

SetValue(double)

Sets the numeric value of the cell. 設定儲存格的數值。

public void SetValue(double val)

Parameters

val double

The numeric value. / 數值。

SetValue(string)

Sets the text content of the cell. 設定儲存格的文字內容。

public void SetValue(string text)

Parameters

text string

The text string. / 文字字串。