[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Fundamental Concepts
    [Expand]Basic Terms
    [Expand]Print Preview
      Export to PDF
      Export to HTML
      Export to MHT
      Export to Text
      Export to CSV
      Export to XLS
      Export to XLSX
      Export to RTF
      Export to DOCX
      Export to Image
      Export to MailMessage
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Export to MHT

This document details the export of a document to MHT format.


A code example illustrating how to export a report to MHT is available at How to export a report to MHT format.

The options that can be specified for a document exported to an MHT file are stored in the MhtExportOptions class, and can be accessed via a report's ExportOptions.Mht property.

Among these options, the HtmlExportOptionsBase.ExportMode property determines the way in which a document is exported to MHT. For instance, it may be exported to a single file (with a single page header at the beginning and a single page footer at the end) or it may be exported page-by-page to either a single file or different files.

The HtmlExportOptionsBase.TableLayout property determines whether or not to use the table layout in the resulting MHT file. If this property is set to false, the non-table layout is used instead. The table layout is recommended, as it uses a more compact and efficient markup.

Note that only the report controls that do not intersect with each other can be correctly exported to MHT using the table layout. In other cases, a layout of the resulting MHT file may be completely broken.

To make sure that your report layout will be preserved in MHT format, enable the report's DesignerOptions.ShowExportWarnings property at design time and check to ensure there are no exclamation marks shown indicating intersecting controls (colored in red).

If you need to export a report that contains intersecting controls to MHT, use the non-table layout.

Document Compatibility Options

By default, the document styles are written to the <head> section of an MHT document, and become ignored by some mail clients. To maintain a consistent look for your reports, set the HtmlExportOptionsBase.InlineCss property to true. In this case, the style properties will be defined at the same place where a specific style is assigned in a document. This will ensure that the resulting document is compatible with any mail client (although at the expense of a larger document size).

This property also affects how the XRPictureBox and XRBarCode controls are rendered on a web page. By default, images corresponding to rendered controls are assigned to the background-image property of styles that are specified in the <head> section of an HTML document. Setting the HtmlExportOptionsBase.InlineCss property to true will make these controls rendered as <img> elements in the document body, with the src attribute specifying a base64 image representation.

Vector images (e.g., pictures (see XRPictureBox), charts or bar codes) are always rasterized on export to MHT. You can use the PageByPageExportOptionsBase.RasterizationResolution property to define the image resolution.

By default, the document navigation is implemented by using scripts. To enable the use of standard HTML link references in document navigation, set the HtmlExportOptionsBase.UseHRefHyperlinks property to true. On viewing such a document in a client web browser, unnecessary script security messages will not be displayed. When this property is enabled, links with empty text may be generated if a corresponding control's content is not specified. It will be impossible to click such links in a published document.

Is this topic helpful?​​​​​​​