Back to Devexpress

Cell.GetRtfContent() Method

officefileapi-devexpress-dot-spreadsheet-dot-cell-8da33f03.md

latest2.4 KB
Original Source

Cell.GetRtfContent() Method

Gets cell content as a string in RTF format.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
string GetRtfContent()
vb
Function GetRtfContent As String

Returns

TypeDescription
String

The string that contains cell content in RTF format.

|

Remarks

Use the GetRtfContent method to export cell content to RTF and obtain the result as a string.

Example

The following snippet loads a document from a file and exports contents of cell B2. The cell contains rich-formatted text with 3 text runs.

cs
using DevExpress.Spreadsheet;
using DevExpress.XtraSpreadsheet.Export;
//... 
using (Workbook workbook = new Workbook()) {
    workbook.LoadDocument("Documents\\Document.xlsx", DocumentFormat.Xlsx);
    workbook.Calculate();

    Worksheet worksheet = workbook.Worksheets[0];
    Cell cell = worksheet[3, 1]; //B2
    string rtfContentString = cell.GetRtfContent(htmlExportOptions);
}
vb
Imports DevExpress.Spreadsheet
Imports DevExpress.XtraSpreadsheet.Export
'... 
Using workbook As New Workbook()
    workbook.LoadDocument("Documents\Document.xlsx", DocumentFormat.Xlsx)
    workbook.Calculate()

    Dim worksheet As Worksheet = workbook.Worksheets(0)
    Dim cell As Cell = worksheet(3, 1) 'B2
    Dim rtfContentString As String = cell.GetRtfContent(htmlExportOptions)
End Using

The resulting string looks as follows:

ets
{\rtf1\deff0{\fonttbl{\f0 Calibri;}{\f1 Arial;}{\f2 Tahoma;}{\f3 Castellar;}}{\colortbl;\red197\green159\blue201;\red44\green96\blue142;\red47\green36\blue79;}{\cf1\f1\fs28 Rich }{\cf2\f2\fs28 text }{\cf3\f3\fs28 formatting}}

See Also

Cell Interface

Cell Members

DevExpress.Spreadsheet Namespace