您的位置:首页 > 其它

水日报表的使用小结

2005-08-19 10:05 761 查看
命名空间:
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.解决经典错误的办法如上代码所示,要手动建立TableLogonInfo和ReportDocumen两个类:
3.在TableLogonInfo中装配表的登陆信息,在ReportDocument中装入.rpt文件:
4.指定ReportDocument中涉及到的数据库各表的登陆信息:TableLogonInfo;
5.指定CrystalReportViewer的ReportSource为上述准备好的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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: