彩票走势图

如何使用XtraReport将报表导出为RTF格式

原创|其它|编辑:郝浩|2012-11-30 14:17:19.000|阅读 518 次

概述:下面的示例演示了如何使用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@cahobeh.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP