Class OdfCell
- Namespace
- OdfKit.Spreadsheet
- Assembly
- OdfKit.dll
Represents a cell in an ODF spreadsheet. 表示 ODF 工作表中的一個儲存格。
public class OdfCell
- Inheritance
-
OdfCell
- Inherited Members
Remarks
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
nodeOdfNodeThe cell XML node. / 儲存格 XML 節點。
rowintThe zero-based row index. / 採 0 為基準的列索引。
colintThe zero-based column index. / 採 0 為基準的欄索引。
docSpreadsheetDocumentThe spreadsheet document. / 試算表文件。
sheetNamestringThe containing sheet name. / 所在工作表名稱。
Remarks
Properties
CellValue
Gets or sets the commonly typed cell value. 取得或設定儲存格的常用型別值。
public object? CellValue { get; set; }
Property Value
Column
Gets the zero-based column index. 取得以 0 為基準的欄索引。
public int Column { get; }
Property Value
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
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
Formula
Gets or sets the cell formula. 取得或設定儲存格的公式。
public string Formula { get; set; }
Property Value
RawValue
Gets or sets the raw numeric cell value as the office:value attribute string.
取得或設定儲存格的原始數值(office:value 屬性,字串格式)。
public string RawValue { get; set; }
Property Value
RichText
Gets the fluent rich text builder for this cell. 取得此儲存格的富文字鏈式建構器。
public OdfCellRichTextBuilder RichText { get; }
Property Value
Row
Gets the zero-based row index. 取得以 0 為基準的列索引。
public int Row { get; }
Property Value
Style
Gets the high-level style configuration facade for this cell. 取得此儲存格的高階樣式設定代理 Facade。
public OdfCellStyleProxy Style { get; }
Property Value
StyleName
Gets or sets the table style name applied to the cell. 取得或設定儲存格套用的表格樣式名稱。
public string? StyleName { get; set; }
Property Value
ValueType
Gets or sets the type of the cell data value. 取得或設定儲存格資料值的型態。
public string ValueType { get; set; }
Property Value
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
AddConditionalFormatMap(string, string, OdfCellAddress?)
Adds a conditional formatting map rule. 新增條件格式對應規則。
public void AddConditionalFormatMap(string condition, string applyStyleName, OdfCellAddress? baseCell)
Parameters
conditionstringThe condition value, such as
cell-content()=1. / 條件值,例如cell-content()=1。applyStyleNamestringThe formatting style name to apply. / 要套用的格式樣式名稱。
baseCellOdfCellAddress?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
htmlstringThe 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
markdownstringThe 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
GetHyperlinkUrl()
Gets the hyperlink URL of the cell, or null when no hyperlink exists. 取得儲存格的超連結 URL;若無超連結則回傳 null。
public string? GetHyperlinkUrl()
Returns
GetRichText()
Gets the rich text content of the cell, or null when it is plain text or empty. 取得儲存格的富文字內容;若為純文字或空白則回傳 null。
public OdfRichText? GetRichText()
Returns
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
TThe target value type. / 目標值型別。
RemoveAnnotation()
Removes the cell annotation. 移除儲存格的批注。
public bool RemoveAnnotation()
Returns
RemoveHyperlink()
Removes the hyperlink of the cell while preserving display text. 移除儲存格的超連結,保留顯示文字。
public bool RemoveHyperlink()
Returns
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
textstring
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
SetAnnotation(string, string?, bool)
Sets the cell annotation and overwrites any existing annotation. 設定儲存格的批注。若已有批注則覆蓋。
public void SetAnnotation(string text, string? author, bool visible)
Parameters
textstringThe annotation content. / 批注內容。
authorstringThe author name. / 作者名稱。
visibleboolWhether 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
topOdfBorder?The top border. / 上框線。
bottomOdfBorder?The bottom border. / 下框線。
leftOdfBorder?The left border. / 左框線。
rightOdfBorder?The right border. / 右框線。
SetFormula(string, object?)
Sets this cell's formula and cached display value. 設定此儲存格的公式與快取顯示值。
public void SetFormula(string formula, object? cachedValue)
Parameters
formulastringThe ODF formula text; an empty value clears the formula. / ODF 公式文字;空值會清除公式。
cachedValueobjectThe cached value stored with the formula. / 隨公式儲存的快取值。
SetHyperlink(string)
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
urlstring
SetHyperlink(string, string?)
Sets the hyperlink of the cell. 設定儲存格的超連結。
public void SetHyperlink(string url, string? displayText)
Parameters
urlstringThe hyperlink URL. / 超連結 URL。
displayTextstringThe 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
richTextOdfRichTextThe 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
textstringThe text content to write. / 要寫入的文字內容。
optionsOdfTextFontFallbackOptionsThe font fallback options. / 字型遞補選項。
SetValue(bool)
Sets the Boolean value of the cell. 設定儲存格的布林值。
public void SetValue(bool val)
Parameters
valboolThe 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
dateDateTime
SetValue(DateTime, bool)
Sets the date and time value of the cell. 設定儲存格的日期時間值。
public void SetValue(DateTime date, bool useTimezoneNaive)
Parameters
dateDateTimeThe date and time value. / 日期時間。
useTimezoneNaiveboolWhether 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
valdoubleThe numeric value. / 數值。
SetValue(string)
Sets the text content of the cell. 設定儲存格的文字內容。
public void SetValue(string text)
Parameters
textstringThe text string. / 文字字串。