我已经做好了水晶报表,文件为1..rpt,我该怎么把它在WEB上通过按钮事件导出来呢,比如导为PDF文件?
弄了一下下午,还是没弄好,求教给个例子吧,谢谢了

解决方案 »

  1.   

    使用ReportView绑定 rpt 在IE上显示时 有导出按钮
      

  2.   

    或是
    ReportDocument rpt=new ReportDocument();   
    rpt.Load(Server.MapPath(".") +  "\\MyReport.rpt");   
    rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat,Response,false,"MyReport");   
      

  3.   

    那个方式老板不要,他要通过WEB按钮来提交导出....
      

  4.   

    this.CrystalReportSource1.ReportDocument.SetDataSource(dsCase.Tables["数据集中存放数据的那个表的名称"]);
    我用了你的代码,可是,我还是不太明白["数据集中存放数据的那个表的名称"]是什么?
    我的水晶报表是从两个库表来生成数据的,我该怎么写你所得那个["数据集中存放数据的那个表的名称"]?
      

  5.   

    http://blog.csdn.net/pfworld/archive/2008/01/03/2022145.aspx刚好在winform内写了一个!可以参考一下!
      

  6.   

    好像BLOG打不开!给你帖这里!!   CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
                this.reportDocument1.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;            SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
                SaveFileDialog1.Filter = "Microsoft Office Excel 文件 (*.xls)|*.xls|Microsoft Office Word 文件 (*.doc)|*.doc|Microsoft Office RichText 文件 (*.rtf)|*.rtf|Adobe PDF 文件 (*.pdf)|*.pdf";
                SaveFileDialog1.FilterIndex = 1;         //默认Microsoft Office Excel
                SaveFileDialog1.RestoreDirectory = true;
                SaveFileDialog1.FileName = "报表_" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;  //默认图片保存名称 Pic01            if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    switch (SaveFileDialog1.FilterIndex)
                    {
                        case 1:
                            this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;
                            break;
                        case 2:
                            this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.WordForWindows;
                            break;
                        case 3:
                            this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.RichText;
                            break;
                        case 4:
                            this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                            break;
                    }
                    DiskOpts.DiskFileName = SaveFileDialog1.FileName;
                    this.reportDocument1.ExportOptions.DestinationOptions = DiskOpts;
                    this.reportDocument1.Export();                MessageBox.Show("数据导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }  
      

  7.   


    this.CrystalReportSource1.ReportDocument.SetDataSource(dsCase.Tables["数据集中存放数据的那个表的名称"]); 
    我用了你的代码,可是,我还是不太明白["数据集中存放数据的那个表的名称"]是什么? 
    我的水晶报表是从两个库表来生成数据的,我该怎么写你所得那个["数据集中存放数据的那个表的名称"]?
    ——————————————————————————————————————
    我这里有个解决这个问题的方法你看看!
    http://blog.csdn.net/pfworld/archive/2007/07/29/1715299.aspx
      

  8.   


    ReportDocument rpt = new ReportDocument();
    rpt.Load(Server.MapPath(".") + @"\kevin.rpt");
    rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "MyReport"); 我不过是把2楼兄弟的代码修改了一下,改了一个参数.这样就能导出成pdf了,而不是在pdf中打开.
      

  9.   

    谢谢楼上的,再问一下,那个reportDocument1是个什么变量?
      

  10.   

    我用了
    ReportDocument rpt = new ReportDocument();
    rpt.Load(Server.MapPath(".") + @"\kevin.rpt");
    rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "MyReport");
    这个方法,系统会说数据库登陆失败,我该怎么设置登陆用户名那些的呢?