原創|其它|編輯:郝浩|2012-11-30 14:17:19.000|閱讀 556 次
概述:下面的示例演示了如何使用XtraReport將報表導出為RTF格式,會用到其中的XtraReport.ExportToRtf方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
下面的示例演示了如何使用XtraReport將報表導出為RTF格式,會用到其中的XtraReport.ExportToRtf方法,這個示例的第一步是需要添加一個新報表(命名為XtraReport1)到你的項目中,將報表控件拖放到里面,然后執行下面的代碼。需要注意,如果您希望生成的文件在用于打開系統*.rtf 文件的默認程序中自動打開,你可以調用StartProcess方法,在這個示例中也會演示到。
C#
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.rtf"; // Create a report instance. XtraReport1 report = new XtraReport1(); // Export the report to RTF. report.ExportToRtf(reportPath); // Show the result. StartProcess(reportPath); } // Use this method if you want to automaically open // the created RTF 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.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.rtf" ' Create a report instance. Dim report As New XtraReport1() ' Export the report to RTF. report.ExportToRtf(reportPath) ' Show the result. StartProcess(reportPath) End Sub ' Use this method if you want to automaically open ' the created RTF 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
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網