Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

CellRange.SetValueFromText(String) Method

Parses the supplied string and creates a cell value to assign it to the cells in the current range.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.2.Core.dll

Declaration

void SetValueFromText(
    string value
)

Parameters

Name Type Description
value String

A string to parse.

Remarks

The SetValueFromText method calls the default worksheet parser which is normally used to parse the input of the cell editor. The cell number format is set to the default number format for the value type assigned to the cell.

Example

This example demonstrates how to use the CellRange.SetValueFromText method to parse the specified string and add data of different types to worksheet cells. To retain the Formatting.NumberFormat of the current cell, when calling the method, set the second parameter to true.

For details on how to access an individual cell or range of cells, refer to the How to: Access a Cell in a Worksheet or How to: Access a Range of Cells document.

// Add data of different types to cells.
worksheet.Cells["B1"].SetValueFromText("27-Jul-16 5:43PM");
worksheet.Cells["B2"].SetValueFromText("3.1415926536");
worksheet.Cells["B3"].SetValueFromText("Have a nice day!");
worksheet.Cells["B4"].SetValueFromText("#REF!");
worksheet.Cells["B5"].SetValueFromText("true");
worksheet.Cells["B6"].SetValueFromText("3.40282E+38");
worksheet.Cells["B7"].SetValueFromText("2147483647");
worksheet.Cells["B8"].NumberFormat = "###.###";
worksheet.Cells["B8"].SetValueFromText("27-Jul-16 5:43PM", true);
worksheet.Cells["B9"].SetValueFromText("=SQRT(25)");

// Fill all cells in the range with 10.
worksheet.Range["C11:F11"].SetValueFromText("=B1");
See Also