New to Telerik Document ProcessingStart a free 30-day trial

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:

C#
public static class CellValueFactory

Inheritance: objectCellValueFactory

Methods

Creates a boolean cell value from a bool.

C#
public static ICellValue Create(bool value)
Parameters:valuebool

The value.

Returns:

ICellValue

The ICellValue instance.

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

C#
public static ICellValue Create(DateTime value)
Parameters:valueDateTime

The value.

Returns:

ICellValue

The ICellValue instance.

Creates a number cell value from a double.

C#
public static ICellValue Create(double value)
Parameters:valuedouble

The value.

Returns:

ICellValue

The ICellValue instance.

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.

C#
public static void Create(string value, Worksheet worksheet, CellIndex cellIndex, CellValueFormat currentFormatValue, out ICellValue cellValue, out CellValueFormat newFormatValue)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

cellIndexCellIndex

Index of the cell.

currentFormatValueCellValueFormat

The current format value.

cellValueICellValue

The cell value.

newFormatValueCellValueFormat

The new format value.

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.

C#
public static void Create(string value, Worksheet worksheet, int rowIndex, int columnIndex, CellValueFormat currentFormatValue, out ICellValue cellValue, out CellValueFormat newFormatValue)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

rowIndexint

Index of the row.

columnIndexint

Index of the column.

currentFormatValueCellValueFormat

The current format value.

cellValueICellValue

The cell value.

newFormatValueCellValueFormat

The format value.

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

C#
public static ICellValue CreateFormulaCellValue(string value, Worksheet worksheet, int rowIndex, int columnIndex)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

rowIndexint

Index of the row.

columnIndexint

Index of the column.

Returns:

ICellValue

The ICellValue instance.

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

C#
public static ICellValue CreateTextCellValue(string value)
Parameters:valuestring

The value.

Returns:

ICellValue

The ICellValue instance.

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

C#
public static CellValueType GetCellValueType(this ConstantExpression value)
Parameters:valueConstantExpression

The expression.

Returns:

CellValueType

The cell value type.

Converts a boolean value to a boolean cell value.

C#
public static ICellValue ToCellValue(this bool value)
Parameters:valuebool

The value.

Returns:

ICellValue

The ICellValue instance.

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

C#
public static ICellValue ToCellValue(this CellIndex value, Worksheet worksheet)
Parameters:valueCellIndex

The value.

worksheetWorksheet

The worksheet.

Returns:

ICellValue

The ICellValue instance.

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.

C#
public static ICellValue ToCellValue(this DateTime value)
Parameters:valueDateTime

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.

Converts a double value to a number cell value.

C#
public static ICellValue ToCellValue(this double value)
Parameters:valuedouble

The value.

Returns:

ICellValue

The ICellValue instance.

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.

C#
public static ICellValue ToCellValue(this string value, Worksheet worksheet, CellIndex cellIndex)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

cellIndexCellIndex

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.

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.

C#
public static ICellValue ToCellValue(this string value, Worksheet worksheet, int rowIndex, int columnIndex)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

rowIndexint

Index of the row.

columnIndexint

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.

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

C#
public static ICellValue ToFormulaCellValue(this string value, Worksheet worksheet, int rowIndex, int columnIndex)
Parameters:valuestring

The value.

worksheetWorksheet

The worksheet.

rowIndexint

Index of the row.

columnIndexint

Index of the column.

Returns:

ICellValue

The FormulaCellValue instance.

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

C#
public static ICellValue ToTextCellValue(this string value)
Parameters:valuestring

The value.

Returns:

ICellValue

The TextCellValue instance.