Table of Contents

Class OdfSheetBuilder

Namespace
OdfKit.Spreadsheet
Assembly
OdfKit.dll

Builds worksheet content with a fluent API. 提供工作表內容的 Fluent 建立 API。

public sealed class OdfSheetBuilder
Inheritance
OdfSheetBuilder
Inherited Members

Methods

AddChart(OdfCellAddress, OdfChartDefinition)

Adds an embedded chart to the current worksheet. 在目前工作表新增嵌入圖表。

public OdfSheetBuilder AddChart(OdfCellAddress anchor, OdfChartDefinition chart)

Parameters

anchor OdfCellAddress

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

chart OdfChartDefinition

The value to use. / 圖表定義

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddChart(string, OdfChartDefinition)

Adds an embedded chart to the current worksheet. 在目前工作表新增嵌入圖表。

public OdfSheetBuilder AddChart(string anchor, OdfChartDefinition chart)

Parameters

anchor string

The cell address. / 圖表左上角錨定儲存格,例如 F1

chart OdfChartDefinition

The value to use. / 圖表定義

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddColorScaleFormat(OdfCellRange, OdfColor, OdfColor)

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

public OdfSheetBuilder AddColorScaleFormat(OdfCellRange range, OdfColor minColor, OdfColor maxColor)

Parameters

range OdfCellRange
minColor OdfColor
maxColor OdfColor

Returns

OdfSheetBuilder

AddColorScaleFormat(OdfCellRange, OdfColor, OdfColor, OdfColor?)

Adds a color scale conditional format. 新增色階條件格式。

public OdfSheetBuilder AddColorScaleFormat(OdfCellRange range, OdfColor minColor, OdfColor maxColor, OdfColor? midColor)

Parameters

range OdfCellRange

The cell range. / 儲存格範圍

minColor OdfColor

The numeric value. / 最小值對應色彩

maxColor OdfColor

The numeric value. / 最大值對應色彩

midColor OdfColor?

The numeric value. / 中間值對應色彩

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddConditionalFormat(OdfCellRange, string, string)

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

public OdfSheetBuilder AddConditionalFormat(OdfCellRange range, string conditionValue, string styleName)

Parameters

range OdfCellRange

The cell range. / 儲存格範圍

conditionValue string

The value to use. / 條件運算式

styleName string

The name or identifier. / 要套用的格式樣式名稱

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddConditionalFormat(string, string, string)

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

public OdfSheetBuilder AddConditionalFormat(string range, string conditionValue, string styleName)

Parameters

range string

The cell range. / 儲存格範圍字串,例如 D2:D20

conditionValue string

The value to use. / 條件運算式

styleName string

The name or identifier. / 要套用的格式樣式名稱

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddDataBarFormat(OdfCellRange, OdfColor)

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

public OdfSheetBuilder AddDataBarFormat(OdfCellRange range, OdfColor positiveColor)

Parameters

range OdfCellRange
positiveColor OdfColor

Returns

OdfSheetBuilder

AddDataBarFormat(OdfCellRange, OdfColor, OdfColor?)

Adds a data bar conditional format. 新增資料橫條條件格式。

public OdfSheetBuilder AddDataBarFormat(OdfCellRange range, OdfColor positiveColor, OdfColor? negativeColor)

Parameters

range OdfCellRange

The cell range. / 儲存格範圍

positiveColor OdfColor

The numeric value. / 正值橫條色彩

negativeColor OdfColor?

The numeric value. / 負值橫條色彩

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddDataValidation(OdfDataValidation)

Adds a data validation rule. 新增資料驗證規則。

public OdfSheetBuilder AddDataValidation(OdfDataValidation validation)

Parameters

validation OdfDataValidation

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

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddDecimalValidation(OdfCellRange, double, double)

Adds a decimal numeric range data validation rule. 新增十進位數值範圍資料驗證規則。

public OdfSheetBuilder AddDecimalValidation(OdfCellRange range, double minimum, double maximum)

Parameters

range OdfCellRange
minimum double
maximum double

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddDecimalValidation(OdfCellRange, double, double, string?, string?)

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

public OdfSheetBuilder AddDecimalValidation(OdfCellRange range, double minimum, double maximum, string? errorTitle, string? errorMessage)

Parameters

range OdfCellRange
minimum double
maximum double
errorTitle string
errorMessage string

Returns

OdfSheetBuilder

AddDecimalValidation(OdfCellRange, double, double, string?, string?, OdfValidationAlertStyle)

Full overload of AddDecimalValidation that accepts range, minimum, maximum, errorTitle, errorMessage, and alertStyle. AddDecimalValidation 完整多載:接受 range、minimum、maximum、errorTitle、errorMessage 與 alertStyle。

public OdfSheetBuilder AddDecimalValidation(OdfCellRange range, double minimum, double maximum, string? errorTitle, string? errorMessage, OdfValidationAlertStyle alertStyle)

Parameters

range OdfCellRange
minimum double
maximum double
errorTitle string
errorMessage string
alertStyle OdfValidationAlertStyle

Returns

OdfSheetBuilder

AddDecimalValidation(string, double, double)

Adds a decimal numeric range data validation rule. 新增十進位數值範圍資料驗證規則。

public OdfSheetBuilder AddDecimalValidation(string range, double minimum, double maximum)

Parameters

range string
minimum double
maximum double

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddDecimalValidation(string, double, double, string?, string?)

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

public OdfSheetBuilder AddDecimalValidation(string range, double minimum, double maximum, string? errorTitle, string? errorMessage)

Parameters

range string
minimum double
maximum double
errorTitle string
errorMessage string

Returns

OdfSheetBuilder

AddDecimalValidation(string, double, double, string?, string?, OdfValidationAlertStyle)

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

public OdfSheetBuilder AddDecimalValidation(string range, double minimum, double maximum, string? errorTitle, string? errorMessage, OdfValidationAlertStyle alertStyle)

Parameters

range string
minimum double
maximum double
errorTitle string
errorMessage string
alertStyle OdfValidationAlertStyle

Returns

OdfSheetBuilder

AddFormulaColumn(string, string, int, int, Func<int, string>)

Adds a formula column with a header cell and formulas for the specified data rows. 新增公式欄,包含標題儲存格與指定資料列的公式。

public OdfSheetBuilder AddFormulaColumn(string columnName, string header, int firstDataRow, int lastDataRow, Func<int, string> formulaFactory)

Parameters

columnName string

The name or identifier. / 欄位名稱,例如 D

header string

The name or identifier. / 標題列文字

firstDataRow int

The numeric value. / 第一筆資料列,採 1 為基準

lastDataRow int

The numeric value. / 最後一筆資料列,採 1 為基準

formulaFactory Func<int, string>

The delegate to invoke. / 依 1-based 列號產生 ODF 公式文字的委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddFormulaColumn(string, string, int, int, Func<int, string>, Func<int, object?>)

Adds a formula column with cached values for the specified data rows. 新增公式欄,並為指定資料列寫入快取值。

public OdfSheetBuilder AddFormulaColumn(string columnName, string header, int firstDataRow, int lastDataRow, Func<int, string> formulaFactory, Func<int, object?> cachedValueFactory)

Parameters

columnName string

The column name, such as D. / 欄位名稱,例如 D

header string

The header text. / 標題列文字。

firstDataRow int

The first one-based data row. / 第一筆資料列,採 1 為基準。

lastDataRow int

The last one-based data row. / 最後一筆資料列,採 1 為基準。

formulaFactory Func<int, string>

The formula factory using one-based row numbers. / 依 1 為基準列號產生 ODF 公式文字的委派。

cachedValueFactory Func<int, object>

The cached value factory using one-based row numbers. / 依 1 為基準列號產生快取值的委派。

Returns

OdfSheetBuilder

The current builder instance. / 目前 builder 執行個體。

AddFormulaColumn(string, string, int, int, Func<int, string>, Func<int, object?>, int)

Full overload of AddFormulaColumn that accepts columnName, header, firstDataRow, lastDataRow, and headerRow. AddFormulaColumn 完整多載:接受 columnName、header、firstDataRow、lastDataRow 與 headerRow。

public OdfSheetBuilder AddFormulaColumn(string columnName, string header, int firstDataRow, int lastDataRow, Func<int, string> formulaFactory, Func<int, object?> cachedValueFactory, int headerRow)

Parameters

columnName string
header string
firstDataRow int
lastDataRow int
formulaFactory Func<int, string>
cachedValueFactory Func<int, object>
headerRow int

Returns

OdfSheetBuilder

AddFormulaColumn(string, string, int, int, Func<int, string>, int)

Full overload of AddFormulaColumn that accepts columnName, header, firstDataRow, lastDataRow, and headerRow. AddFormulaColumn 完整多載:接受 columnName、header、firstDataRow、lastDataRow 與 headerRow。

public OdfSheetBuilder AddFormulaColumn(string columnName, string header, int firstDataRow, int lastDataRow, Func<int, string> formulaFactory, int headerRow)

Parameters

columnName string
header string
firstDataRow int
lastDataRow int
formulaFactory Func<int, string>
headerRow int

Returns

OdfSheetBuilder

AddIconSetFormat(OdfCellRange, OdfIconSetType)

Adds an icon set conditional format. 新增圖示集條件格式。

public OdfSheetBuilder AddIconSetFormat(OdfCellRange range, OdfIconSetType iconSet)

Parameters

range OdfCellRange

The cell range. / 儲存格範圍

iconSet OdfIconSetType

The value to use. / 圖示集類型

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

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 OdfSheetBuilder AddNamedExpression(string name, string expression)

Parameters

name string
expression string

Returns

OdfSheetBuilder

AddNamedExpression(string, string, OdfCellAddress?)

Adds a worksheet-level named expression. 新增工作表層具名運算式。

public OdfSheetBuilder 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. / 基準儲存格位址

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

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 OdfSheetBuilder AddNamedRange(string name, OdfCellRange range)

Parameters

name string
range OdfCellRange

Returns

OdfSheetBuilder

AddNamedRange(string, OdfCellRange, OdfCellAddress?)

Adds a worksheet-level named range. 新增工作表層命名範圍。

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

Parameters

name string

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

range OdfCellRange

The cell range. / 儲存格範圍

baseCell OdfCellAddress?

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

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddNamedRange(string, string)

Adds a worksheet-level named range. 新增工作表層命名範圍。

public OdfSheetBuilder AddNamedRange(string name, string range)

Parameters

name string

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

range string

The cell range. / 儲存格範圍字串,例如 A1:D10

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddPivotTable(OdfCellRange, OdfCellAddress, Action<OdfPivotTableBuilder>)

Adds a pivot table. 新增樞紐分析表。

public OdfSheetBuilder AddPivotTable(OdfCellRange sourceRange, OdfCellAddress targetCell, Action<OdfPivotTableBuilder> configure)

Parameters

sourceRange OdfCellRange

The cell range. / 來源資料範圍

targetCell OdfCellAddress

The cell address. / 輸出起點儲存格

configure Action<OdfPivotTableBuilder>

The delegate to invoke. / 樞紐分析表設定委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddPivotTable(string, OdfCellRange, OdfCellAddress, Action<OdfPivotTableBuilder>)

Adds a pivot table. 新增樞紐分析表。

public OdfSheetBuilder AddPivotTable(string name, OdfCellRange sourceRange, OdfCellAddress targetCell, Action<OdfPivotTableBuilder> configure)

Parameters

name string

The name or identifier. / 樞紐分析表名稱

sourceRange OdfCellRange

The cell range. / 來源資料範圍

targetCell OdfCellAddress

The cell address. / 輸出起點儲存格

configure Action<OdfPivotTableBuilder>

The delegate to invoke. / 樞紐分析表設定委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

AddPivotTable(string, string, string, Action<OdfPivotTableBuilder>)

Adds a pivot table. 新增樞紐分析表。

public OdfSheetBuilder AddPivotTable(string name, string sourceRange, string targetCell, Action<OdfPivotTableBuilder> configure)

Parameters

name string

The name or identifier. / 樞紐分析表名稱

sourceRange string

The cell range. / 來源資料範圍字串,例如 A1:D20

targetCell string

The cell address. / 輸出起點儲存格,例如 G1

configure Action<OdfPivotTableBuilder>

The delegate to invoke. / 樞紐分析表設定委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

FreezeAt(int, int)

Freezes panes above and to the left of the specified cell. 凍結指定儲存格上方與左側的窗格。

public OdfSheetBuilder FreezeAt(int row, int column)

Parameters

row int

The numeric value. / 作用儲存格列,採 1 為基準

column int

The numeric value. / 作用儲存格欄,採 1 為基準

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

ImportRows<T>(IEnumerable<T>, Func<T, object?[]>)

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

public OdfSheetBuilder ImportRows<T>(IEnumerable<T> items, Func<T, object?[]> selector)

Parameters

items IEnumerable<T>
selector Func<T, object[]>

Returns

OdfSheetBuilder

Type Parameters

T

ImportRows<T>(IEnumerable<T>, Func<T, object?[]>, int)

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

public OdfSheetBuilder ImportRows<T>(IEnumerable<T> items, Func<T, object?[]> selector, int startRow)

Parameters

items IEnumerable<T>
selector Func<T, object[]>
startRow int

Returns

OdfSheetBuilder

Type Parameters

T

ImportRows<T>(IEnumerable<T>, Func<T, object?[]>, int, int)

Imports row data. 匯入列資料。

public OdfSheetBuilder ImportRows<T>(IEnumerable<T> items, Func<T, object?[]> selector, int startRow, int startColumn)

Parameters

items IEnumerable<T>

The value to use. / 要匯入的資料專案

selector Func<T, object[]>

The delegate to invoke. / 將資料專案轉為儲存格值陣列的委派

startRow int

The numeric value. / 起始列,採 1 為基準

startColumn int

The numeric value. / 起始欄,採 1 為基準

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

Type Parameters

T

The type of item. / 資料專案型別

ImportTable<T>(IEnumerable<T>, Func<T, object?[]>, IEnumerable<string>)

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

public OdfSheetBuilder ImportTable<T>(IEnumerable<T> items, Func<T, object?[]> rowSelector, IEnumerable<string> headers)

Parameters

items IEnumerable<T>
rowSelector Func<T, object[]>
headers IEnumerable<string>

Returns

OdfSheetBuilder

Type Parameters

T

ImportTable<T>(IEnumerable<T>, Func<T, object?[]>, IEnumerable<string>, int)

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

public OdfSheetBuilder ImportTable<T>(IEnumerable<T> items, Func<T, object?[]> rowSelector, IEnumerable<string> headers, int startRow)

Parameters

items IEnumerable<T>
rowSelector Func<T, object[]>
headers IEnumerable<string>
startRow int

Returns

OdfSheetBuilder

Type Parameters

T

ImportTable<T>(IEnumerable<T>, Func<T, object?[]>, IEnumerable<string>, int, int)

Imports a table with a header row. 匯入含標題列的資料表。

public OdfSheetBuilder ImportTable<T>(IEnumerable<T> items, Func<T, object?[]> rowSelector, IEnumerable<string> headers, int startRow, int startColumn)

Parameters

items IEnumerable<T>

The value to use. / 要匯入的資料專案

rowSelector Func<T, object[]>

The delegate to invoke. / 將資料專案轉為儲存格值陣列的委派

headers IEnumerable<string>

The name or identifier. / 標題列文字

startRow int

The numeric value. / 標題列起始列,採 1 為基準

startColumn int

The numeric value. / 標題列起始欄,採 1 為基準

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

Type Parameters

T

The type of item. / 資料專案型別

InsertChart(OdfCellRange, OdfChartType)

Inserts an embedded chart into the current worksheet for immediate configuration. 在目前工作表插入可立即設定的嵌入圖表。

public OdfSheetBuilder InsertChart(OdfCellRange dataRange, OdfChartType chartType)

Parameters

dataRange OdfCellRange
chartType OdfChartType

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

InsertChart(OdfCellRange, OdfChartType, Action<OdfChartDocument>?)

Full overload of InsertChart that accepts dataRange, chartType, and configure. InsertChart 完整多載:接受 dataRange、chartType 與 configure。

public OdfSheetBuilder InsertChart(OdfCellRange dataRange, OdfChartType chartType, Action<OdfChartDocument>? configure)

Parameters

dataRange OdfCellRange
chartType OdfChartType
configure Action<OdfChartDocument>

Returns

OdfSheetBuilder

InsertChart(string, OdfChartType)

Inserts an embedded chart into the current worksheet for immediate configuration. 在目前工作表插入可立即設定的嵌入圖表。

public OdfSheetBuilder InsertChart(string dataRange, OdfChartType chartType)

Parameters

dataRange string
chartType OdfChartType

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

InsertChart(string, OdfChartType, Action<OdfChartDocument>?)

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

public OdfSheetBuilder InsertChart(string dataRange, OdfChartType chartType, Action<OdfChartDocument>? configure)

Parameters

dataRange string
chartType OdfChartType
configure Action<OdfChartDocument>

Returns

OdfSheetBuilder

SetCell(string, object?)

Sets the value of the specified cell. 設定指定儲存格的值。

public OdfSheetBuilder SetCell(string address, object? value)

Parameters

address string

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

value object

The value to use. / 儲存格值

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

SetColumnWidth(int, double)

Sets the column width. 設定欄寬。

public OdfSheetBuilder SetColumnWidth(int columnIndex, double widthCm)

Parameters

columnIndex int

The numeric value. / 欄索引,採 1 為基準

widthCm double

The value to use. / 欄寬,單位為公分

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

SetFormula(string, string)

Sets the formula for the specified cell. 設定指定儲存格的公式。

public OdfSheetBuilder SetFormula(string address, string formula)

Parameters

address string

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

formula string

The value to use. / ODF 公式文字

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

SetFormula(string, string, object?)

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

public OdfSheetBuilder SetFormula(string address, string formula, object? cachedValue)

Parameters

address string

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

formula string

The ODF formula text. / ODF 公式文字。

cachedValue object

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

Returns

OdfSheetBuilder

The current builder instance. / 目前 builder 執行個體。

SetFormulaRange(OdfCellRange, Func<int, int, string>)

Sets formulas cell by cell across the specified cell range. 對指定儲存格範圍逐格設定公式。

public OdfSheetBuilder SetFormulaRange(OdfCellRange range, Func<int, int, string> formulaFactory)

Parameters

range OdfCellRange

The cell range. / 要設定公式的儲存格範圍

formulaFactory Func<int, int, string>

The delegate to invoke. / 依 1-based 列號與欄號產生 ODF 公式文字的委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體

SetFormulaRange(string, Func<int, int, string>)

Sets formulas cell by cell across the specified cell range. 對指定儲存格範圍逐格設定公式。

public OdfSheetBuilder SetFormulaRange(string range, Func<int, int, string> formulaFactory)

Parameters

range string

The cell range. / 儲存格範圍字串,例如 D2:D20

formulaFactory Func<int, int, string>

The delegate to invoke. / 依 1-based 列號與欄號產生 ODF 公式文字的委派

Returns

OdfSheetBuilder

The result. / 目前 builder 執行個體