|
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);