Back to Devexpress

Cell.DisplayText Property

officefileapi-devexpress-dot-spreadsheet-dot-cell-b5a5b9ac.md

latest7.3 KB
Original Source

Cell.DisplayText Property

Returns a cell’s displayed value.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
string DisplayText { get; }
vb
ReadOnly Property DisplayText As String

Property Value

TypeDescription
String

The cell’s display text.

|

Remarks

Use the Cell.Value property to access and modify a cell’s value. A cell can contain different data types. Assign a number format pattern to the Cell.NumberFormat property to format a numeric value in a cell as a percentage, currency, fraction, date and time, and so on. The DisplayText property returns the cell’s formatted value.

csharp
// Add a formula to the cell "A1".
worksheet.Cells["A1"].Formula = "= Now()";
// Format the cell's value.
worksheet.Cells["A1"].NumberFormat = "m/d/yy h:mm";
// Obtain the cell's display text.
// The property returns the current date and time
// (for instance, "6/19/2020 13:13").
string displayText1 = worksheet.Cells["A1"].DisplayText;

// Add a number to the cell "B1".
worksheet.Cells["B1"].Value = 1.6;
// Format the number as a percentage.
worksheet.Cells["B1"].NumberFormat = "0.0%";
// Obtain the cell's display text.
// The property returns "160.0%".
string displayText2 = worksheet.Cells["B1"].DisplayText;
vb
' Add a formula to the cell "A1".
worksheet.Cells("A1").Formula = "= Now()"
' Format the cell's value.
worksheet.Cells("A1").NumberFormat = "m/d/yy h:mm"
' Obtain the cell's display text.
' The property returns the current date and time
' (for instance, "6/19/2020 13:13").
Dim displayText1 As String = worksheet.Cells("A1").DisplayText

' Add a number to the cell "B1".
worksheet.Cells("B1").Value = 1.6
' Format the number as a percentage.
worksheet.Cells("B1").NumberFormat = "0.0%"
' Obtain the cell's display text.
' The property returns "160.0%".
Dim displayText2 As String = worksheet.Cells("B1").DisplayText

The following code snippets (auto-collected from DevExpress Examples) contain references to the DisplayText property.

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.

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/CS/WpfSpreadsheet_BindToDataSource/MainWindow.xaml.cs#L76

csharp
sheet["E4"].Value.TextValue, sheet["E6"].Value.TextValue, sheet["E8"].Value.TextValue,
        sheet.Cells["G4"].DisplayText, sheet.Cells["G6"].DisplayText);
}

spreadsheet-document-api-use-worksheet-table-as-data-source/CS/SpreadsheetDocumentServerAsDataSourceExample/MyColumnDetector.cs#L11

csharp
{
    return range[-1, offset].DisplayText;
}

winforms-spreadsheet-bind-to-ms-sql-server-database/CS/SuppliersExample/Form1.cs#L63

csharp
sheet["E4"].Value.TextValue, sheet["E6"].Value.TextValue, sheet["E8"].Value.TextValue,
        sheet.Cells["G4"].DisplayText, sheet.Cells["G6"].DisplayText);
}

winforms-spreadsheet-how-to-edit-rich-text/VB/SpreadsheetRichText/RichTextEditForm.vb#L46

vb
Else
    RichEditControl1.Text = cell.DisplayText
End If

wpf-spreadsheet-bind-spreadsheet-to-ms-sql-server-database/VB/WpfSpreadsheet_BindToDataSource/MainWindow.xaml.vb#L67

vb
' Append a new row to the "Suppliers" data table.
    dataSet.Suppliers.AddSuppliersRow(sheet("C4").Value.TextValue, sheet("C6").Value.TextValue, sheet("C8").Value.TextValue, sheet("E4").Value.TextValue, sheet("E6").Value.TextValue, sheet("E8").Value.TextValue, sheet.Cells("G4").DisplayText, sheet.Cells("G6").DisplayText)
Catch ex As Exception

spreadsheet-document-api-use-worksheet-table-as-data-source/VB/SpreadsheetDocumentServerAsDataSourceExample/MyColumnDetector.vb#L9

vb
Public Function GetColumnName(ByVal index As Integer, ByVal offset As Integer, ByVal range As CellRange) As String Implements IDataSourceColumnTypeDetector.GetColumnName
    Return range(-1, offset).DisplayText
End Function

winforms-spreadsheet-bind-to-ms-sql-server-database/VB/SuppliersExample/Form1.vb#L61

vb
' Append a new row to the "Suppliers" data table.
    dataSet.Suppliers.AddSuppliersRow(sheet("C4").Value.TextValue, sheet("C6").Value.TextValue, sheet("C8").Value.TextValue, sheet("E4").Value.TextValue, sheet("E6").Value.TextValue, sheet("E8").Value.TextValue, sheet.Cells("G4").DisplayText, sheet.Cells("G6").DisplayText)
Catch ex As Exception

See Also

Value

NumberFormat

How to: Specify Number or Date Format for Cell Content

Cell Interface

Cell Members

DevExpress.Spreadsheet Namespace