Skip to main content
All docs
V24.2
Row

Cell.GetHtmlContent(HtmlCellContentExportOptions) Method

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

Namespace: DevExpress.Spreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

string GetHtmlContent(
    HtmlCellContentExportOptions options
)

Parameters

Name Type Description
options HtmlCellContentExportOptions

A HtmlCellContentExportOptions object that contains export options.

Returns

Type Description
String

The string that contains cell content in HTML format.

Remarks

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

You can specify the following options:

IgnoreDisplayFormat
Gets or sets whether to ignore the display format when exporting cell content to HTML.
FontUnit
Gets or sets the measurement unit to specify font size when exporting to HTML.

Example

The following snippet loads a document from a file and exports content from cell B3. The IgnoreDisplayFormat property is set to true and the FontUnit property is set to Pixel. The cell contains conditional formatting.

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
    HtmlCellContentExportOptions htmlExportOptions = new HtmlCellContentExportOptions();
    htmlExportOptions.IgnoreDisplayFormat = true;
    htmlExportOptions.FontUnit = DevExpress.XtraSpreadsheet.Export.Html.HtmlFontUnit.Pixel;
    string htmlContentString = cell.GetHtmlContent(htmlExportOptions);
}

Spreadsheet - Conditional Formatting

The resulting HTML string looks as follows:

<font style="font-family:Calibri;font-size:15px;font-weight:normal;font-style:normal;color:#FFFFFF;">cell with conditional formatting</font>
See Also