Back to Devexpress

Cell.GetRtfContent(RtfCellContentExportOptions) Method

officefileapi-devexpress-dot-spreadsheet-dot-cell-dot-getrtfcontent-x28-devexpress-dot-xtraspreadsheet-dot-export-dot-rtfcellcontentexportoptions-x29.md

latest3.6 KB
Original Source

Cell.GetRtfContent(RtfCellContentExportOptions) Method

Gets cell content as a string in RTF format. Allows you to specify export options.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
string GetRtfContent(
    RtfCellContentExportOptions options
)
vb
Function GetRtfContent(
    options As RtfCellContentExportOptions
) As String

Parameters

NameTypeDescription
optionsRtfCellContentExportOptions

A RtfCellContentExportOptions object that specifies export settings.

|

Returns

TypeDescription
String

The string that contains cell content in RTF format.

|

Remarks

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

The IgnoreDisplayFormat option allows you to specify whether to ignore the display format.

Example

The following snippet loads a document from a file and exports content from cell B3. The IgnoreDisplayFormat property is set to true:

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[4, 1]; //B3
    RtfCellContentExportOptions rtfExportOptions = new RtfCellContentExportOptions();
    rtfExportOptions.IgnoreDisplayFormat = true;
    string rtfContentString = cell.GetRtfContent(rtfExportOptions);
}
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(4, 1) 'B3
    Dim rtfExportOptions As New RtfCellContentExportOptions()
    rtfExportOptions.IgnoreDisplayFormat = True
    Dim rtfContentString As String = cell.GetRtfContent(rtfExportOptions)
End Using

The resulting HTML string looks as follows:

ets
{\rtf1\deff0{\fonttbl{\f0 Calibri;}}{\colortbl;}{\fs22 cell with conditional formatting}}

See Also

Export Cell Content from Spreadsheet Documents

Cell Interface

Cell Members

DevExpress.Spreadsheet Namespace