原創(chuàng)|其它|編輯:郝浩|2012-11-28 11:37:38.000|閱讀 307 次
概述:下面的例子演示了如何使用XtraReport將報(bào)表導(dǎo)出為MHT格式。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
下面的例子演示了如何使用XtraReport將報(bào)表導(dǎo)出為MHT格式。
C#
using System.Drawing; using System.Diagnostics; using DevExpress.XtraPrinting; using DevExpress.XtraReports.UI; // ... private void button1_Click(object sender, EventArgs e) { // A path to export a report. string reportPath = "c:\\Test.mht"; // Create a report instance. XtraReport1 report = new XtraReport1(); // Get its MHT export options. MhtExportOptions mhtOptions = report.ExportOptions.Mht; // Set MHT-specific export options. mhtOptions.CharacterSet = "UTF-8"; mhtOptions.RemoveSecondarySymbols = false; mhtOptions.Title = "Test Title"; // Set the pages to be exported, and page-by-page options. mhtOptions.ExportMode = HtmlExportMode.SingleFilePageByPage; mhtOptions.PageRange = "1, 3-5"; mhtOptions.PageBorderColor = Color.Blue; mhtOptions.PageBorderWidth = 3; // Export the report to MHT. report.ExportToMht(reportPath); // Show the result. StartProcess(reportPath); } // Use this method if you want to automaically open // the created MHT file in the default program. public void StartProcess(string path) { Process process = new Process(); try { process.StartInfo.FileName = path; process.Start(); process.WaitForInputIdle(); } catch { } } VB
Imports System.Drawing Imports System.Diagnostics Imports DevExpress.XtraPrinting Imports DevExpress.XtraReports.UI ' ... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click ' A path to export a report. Dim reportPath As String = "c:\\Test.mht" ' Create a report instance. Dim report As New XtraReport1() ' Get its MHT export options. Dim mhtOptions As MhtExportOptions = report.ExportOptions.Mht ' Set MHT-specific export options. mhtOptions.CharacterSet = "UTF-8" mhtOptions.RemoveSecondarySymbols = False mhtOptions.Title = "Test Title" ' Set the pages to be exported, and page-by-page options. mhtOptions.ExportMode = HtmlExportMode.SingleFilePageByPage mhtOptions.PageRange = "1, 3-5" mhtOptions.PageBorderColor = Color.Blue mhtOptions.PageBorderWidth = 3 ' Export the report to MHT. report.ExportToMht(reportPath) ' Show the result. StartProcess(reportPath) End Sub ' Use this method if you want to automaically open ' the created MHT file in the default program. Public Sub StartProcess(ByVal path As String) Dim process As New Process() Try process.StartInfo.FileName = path process.Start() process.WaitForInputIdle() Catch End Try End Sub
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)