Class
CellValueFactory

Factory for creating cell value instances from various input types; use to convert strings, numbers, dates, and formulas into appropriate ICellValue implementations.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Model

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

cs-api-definition
public static class CellValueFactory

Inheritance: objectCellValueFactory

Methods

Create(DateTime)

Creates a number cell value from a DateTime by converting it to Excel's date serial number format.

Declaration

cs-api-definition
public static ICellValue Create(DateTime value)

Parameters

value

DateTime

The value.

Returns

ICellValue

The ICellValue instance.

Create(bool)

Creates a boolean cell value from a bool.

Declaration

cs-api-definition
public static ICellValue Create(bool value)

Parameters

value

bool

The value.

Returns

ICellValue

The ICellValue instance.

Create(double)

Creates a number cell value from a double.

Declaration

cs-api-definition
public static ICellValue Create(double value)

Parameters

value

double

The value.

Returns

ICellValue

The ICellValue instance.

Create(string, Worksheet, CellIndex, CellValueFormat, out ICellValue, out CellValueFormat)

Creates a cell value from a string by parsing its content and determining the appropriate format; outputs both the cell value and any detected format.

Declaration

cs-api-definition
public static void Create(string value, Worksheet worksheet, CellIndex cellIndex, CellValueFormat currentFormatValue, out ICellValue cellValue, out CellValueFormat newFormatValue)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

cellIndex

CellIndex

Index of the cell.

currentFormatValue

CellValueFormat

The current format value.

cellValue

ICellValue

The cell value.

newFormatValue

CellValueFormat

The new format value.

Create(string, Worksheet, int, int, CellValueFormat, out ICellValue, out CellValueFormat)

Creates a cell value from a string by parsing its content at the specified location and determining the appropriate format; outputs both the cell value and any detected format.

Declaration

cs-api-definition
public static void Create(string value, Worksheet worksheet, int rowIndex, int columnIndex, CellValueFormat currentFormatValue, out ICellValue cellValue, out CellValueFormat newFormatValue)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

rowIndex

int

Index of the row.

columnIndex

int

Index of the column.

currentFormatValue

CellValueFormat

The current format value.

cellValue

ICellValue

The cell value.

newFormatValue

CellValueFormat

The format value.

CreateFormulaCellValue(string, Worksheet, int, int)

Creates a formula cell value by parsing the string as an Excel formula expression at the specified location.

Declaration

cs-api-definition
public static ICellValue CreateFormulaCellValue(string value, Worksheet worksheet, int rowIndex, int columnIndex)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

rowIndex

int

Index of the row.

columnIndex

int

Index of the column.

Returns

ICellValue

The ICellValue instance.

CreateTextCellValue(string)

Creates a text cell value from a string without parsing or type detection.

Declaration

cs-api-definition
public static ICellValue CreateTextCellValue(string value)

Parameters

value

string

The value.

Returns

ICellValue

The ICellValue instance.

GetCellValueType(ConstantExpression)

Determines the cell value type that corresponds to a constant expression; returns the appropriate CellValueType for the expression's result.

Declaration

cs-api-definition
public static CellValueType GetCellValueType(this ConstantExpression value)

Parameters

value

ConstantExpression

The expression.

Returns

CellValueType

The cell value type.

ToCellValue(CellIndex, Worksheet)

Retrieves the cell value at the specified cell index from the worksheet.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this CellIndex value, Worksheet worksheet)

Parameters

value

CellIndex

The value.

worksheet

Worksheet

The worksheet.

Returns

ICellValue

The ICellValue instance.

ToCellValue(DateTime)

Converts a DateTime value to a number cell value representing the date; apply a date format to the cell to display as a date instead of a number.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this DateTime value)

Parameters

value

DateTime

The value.

Returns

ICellValue

The ICellValue instance.

Remarks

Please note the date is stored as number value. If a date number format is not set to the cell the value will be shown as number.

ToCellValue(bool)

Converts a boolean value to a boolean cell value.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this bool value)

Parameters

value

bool

The value.

Returns

ICellValue

The ICellValue instance.

ToCellValue(double)

Converts a double value to a number cell value.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this double value)

Parameters

value

double

The value.

Returns

ICellValue

The ICellValue instance.

ToCellValue(string, Worksheet, CellIndex)

Converts a string to a cell value by parsing its content at the specified cell location; string is analyzed to determine if it contains a number, date, formula, or text.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this string value, Worksheet worksheet, CellIndex cellIndex)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

cellIndex

CellIndex

Index of the cell.

Returns

ICellValue

The ICellValue instance.

Remarks

Please note that the string value is parsed to find its type. This process is slow. If you know the type of your data use the other overloads of this method.

ToCellValue(string, Worksheet, int, int)

Converts a string to a cell value by parsing its content at the specified row and column; string is analyzed to determine if it contains a number, date, formula, or text.

Declaration

cs-api-definition
public static ICellValue ToCellValue(this string value, Worksheet worksheet, int rowIndex, int columnIndex)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

rowIndex

int

Index of the row.

columnIndex

int

Index of the column.

Returns

ICellValue

The ICellValue instance.

Remarks

Please note that the string value is parsed to find its type. This process is slow. If you know the type of your data use the other overloads of this method.

ToFormulaCellValue(string, Worksheet, int, int)

Converts a string to a formula cell value by parsing it as an Excel formula at the specified location.

Declaration

cs-api-definition
public static ICellValue ToFormulaCellValue(this string value, Worksheet worksheet, int rowIndex, int columnIndex)

Parameters

value

string

The value.

worksheet

Worksheet

The worksheet.

rowIndex

int

Index of the row.

columnIndex

int

Index of the column.

Returns

ICellValue

The FormulaCellValue instance.

ToTextCellValue(string)

Converts a string to a text cell value without parsing; use when you want to store the string as literal text regardless of content.

Declaration

cs-api-definition
public static ICellValue ToTextCellValue(this string value)

Parameters

value

string

The value.

Returns

ICellValue

The TextCellValue instance.