水日报表的使用小结

命名空间:
1.Engine:
对引擎的支持类。定义了水晶报表里的各种对象及格式的设计 ;
2.shared:
公用类。定义了被 Engine 等公用的类,如数据表登录信息,参数等,主要是一选项。
3.ReportSource:
定义了报表的装载,导入,导出,打印,等属性,方法,事件。
4..Web:
就要用来设置 web 端显示的一些属性。

小示例:
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

CrystalDecisions.Shared.TableLogOnInfo logInfo=new TableLogOnInfo();
   
   CrystalDecisions.CrystalReports.Engine.ReportDocument rp=new ReportDocument();

   logInfo.ConnectionInfo.DatabaseName="ams";
   logInfo.ConnectionInfo.ServerName="dyhcn";
   logInfo.ConnectionInfo.UserID="sa";
   logInfo.ConnectionInfo.Password="12345";

   rp.Load(@"E:/AMS/baams/CrystalReport1.rpt");
   
   rp.Database.Tables[0].ApplyLogOnInfo(logInfo);

   this.CrystalReportViewer1.ReportSource=rp;

****************************************************************************************************************************

1.aspx页面指定reportSource(这样总有错),只能在后台指定:
2.
解决经典错误的办法如上代码所示,要手动建立TableLogonInfoReportDocumen两个类:
3.
TableLogonInfo中装配表的登陆信息,在ReportDocument中装入.rpt文件:
4.
指定ReportDocument中涉及到的数据库各表的登陆信息:TableLogonInfo;
5.
指定CrystalReportViewerReportSource为上述准备好的ReportDocument;
6.
水晶报表的注册码为:注册号:6707437608 密码:AAP5GKS0000GDE100DS

7.导出word,excel,pdf:
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
   diskOpts.DiskFileName = sDestFile;

   oRpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

   switch (sExportFormatType)
   {
    case "Mircrosoft Word
文档":
    {
     oRpt.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
     break;
    }
    case "Mircrosoft Excel
文档":
    {
     oRpt.ExportOptions.ExportFormatType = ExportFormatType.Excel;
     break;
    }
    case "Adobe PDF
文档":
    {
     oRpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
     break;
    }
   }

   oRpt.ExportOptions.DestinationOptions = diskOpts;

   oRpt.Export();

   Response.ClearContent();
   Response.ClearHeaders();

   switch (sExportFormatType)
   {
    case "Mircrosoft Word
文档":
    {
     Response.ContentType = "application/msword";
     break;
    }
    case "Mircrosoft Excel
文档":
    {
     Response.ContentType = "application/vnd.ms-excel";
     break;
    }
    case "Adobe PDF
文档":
    {
     Response.ContentType = "application/pdf";
     break;
    }
   }

   Response.WriteFile(sDestFile);
   Response.Flush();
   Response.Close();

   File.Delete(sDestFile);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值