Skip to main content
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.v23.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

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.

View Example

// 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");

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetValueFromText(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also