officefileapi-devexpress-dot-spreadsheet-dot-cell-dot-gethtmlcontent-x28-devexpress-dot-xtraspreadsheet-dot-export-dot-htmlcellcontentexportoptions-x29.md
Gets cell content as a string in HTML format. Allows you to specify export options.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
string GetHtmlContent(
HtmlCellContentExportOptions options
)
Function GetHtmlContent(
options As HtmlCellContentExportOptions
) As String
| Name | Type | Description |
|---|---|---|
| options | HtmlCellContentExportOptions |
A HtmlCellContentExportOptions object that contains export options.
|
| Type | Description |
|---|---|
| String |
The string that contains cell content in HTML format.
|
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:
IgnoreDisplayFormatGets or sets whether to ignore the display format when exporting cell content to HTML.FontUnitGets or sets the measurement unit to specify font size when exporting to HTML.
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);
}
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 htmlExportOptions As New HtmlCellContentExportOptions()
htmlExportOptions.IgnoreDisplayFormat = True
htmlExportOptions.FontUnit = DevExpress.XtraSpreadsheet.Export.Html.HtmlFontUnit.Pixel
Dim htmlContentString As String = cell.GetHtmlContent(htmlExportOptions)
End Using
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