Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

HtmlDocumentExporterOptions.Range Property

Gets or sets the worksheet range to be exported to an HTML file.

Namespace: DevExpress.XtraSpreadsheet.Export

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

Declaration

[DefaultValue("")]
public string Range { get; set; }

Property Value

Type Default Description
String String.Empty

A String value that represents the exported range.

Remarks

You can specify a data range to be exported to HTML using one of the following methods:

  • Provide the A1-style reference (relative, absolute or mixed) to the required cell range.
  • Provide the R1C1-style reference (relative, absolute or mixed) to the required cell range.
  • Provide the structured reference to a worksheet table or a table data range you wish to export.
  • Assign a defined name that refers to a cell range you wish to export.
  • Use a formula in the invariant culture (English) that returns a cell range to be exported.

Important

While exporting a cell range to an HTML file, you can reference only a contiguous cell range located in a worksheet specified by the HtmlDocumentExporterOptions.SheetIndex property (by default, the first worksheet in a workbook is exported). If you try to export a union range (composed of multiple non-contiguous ranges) or a range located in another worksheet, an ArgumentExeption will be thrown.

Example

The example below demonstrates how to save a worksheet and a cell range as HTML files using the IWorkbook.ExportToHtml method overloads. To specify export options, create an instance of the HtmlDocumentExporterOptions class and pass it as a parameter to the ExportToHtml method.

workbook.LoadDocument("Documents\ExpenseReport.xlsx")
workbook.Calculate()
Dim worksheet As Worksheet = workbook.Worksheets(0)

' Create an object containing HTML export options.
Dim options As New HtmlDocumentExporterOptions()

' Set HTML-specific export options.
options.CssPropertiesExportType = DevExpress.XtraSpreadsheet.Export.Html.CssPropertiesExportType.Style
options.Encoding = Encoding.UTF8

' Specify the part of the document to be exported to HTML.
options.SheetIndex = worksheet.Index
options.Range = "B11:O28"

' Export a document to an HTML file with the specified options.
workbook.ExportToHtml("OutputRange.html", options)

' Export the entire worksheet to a stream as HTML.
Dim htmlStream As New FileStream("OutputWorksheet.html", FileMode.Create)
workbook.ExportToHtml(htmlStream, worksheet.Index)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Range 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.

See Also