日期:2014-05-20 浏览次数:21162 次
ReportDocument reportDocument = new ReportDocument(); reportDocument.Load(@"C:\RptContainer.rpt"); ISCDReportClientDocument reportClientDocument = reportDocument.ReportClientDocument;
using System;
using System.Windows.Forms;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
namespace CS_APP_AddSubReportRuntime
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ReportDocument boReportDocument =new ReportDocument();
ISCDReportClientDocument boReportClientDocument ;
CrystalDecisions.ReportAppServer.Controllers.SubreportClientDocument boSubreportClientDocument;
CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection ;
String strSubRptFile ="";
//加载主报表
boReportDocument.Load(@"E:\CRQuestions\CS_APP_AddSubReportRuntime\Crystalreport1.rpt");
/*----------------------------------------
如果要进行数据、参数、公式操作,请在此处对主报表boReportDocument进行操作
----------------------------------------*/
boReportClientDocument = new ReportClientDocumentClass();
//由主报表返回待RAS操作的ReportClientDocument
boReportClientDocument = boReportDocument.ReportClientDocument;
//获取到第一个section,用来放置子报表
boSection = boReportClientDocument.ReportDefController.ReportDefinition.PageHeaderArea.Sections[0];
//待加载的子报表
strSubRptFile = @"E:\CRQuestions\CS_APP_AddSubReportRuntime\sub1.rpt";
//导入子报表,ss1是子报表对象在主报表上的名称
boSubreportClientDocument = boReportClientDocument.SubreportController.ImportSubreport("ss1", strSubRptFile, boSection);
/*----------------------------------------
如果要进行数据、参数、公式操作,请在此处对子报表boSubreportClientDocument 进行操作
----------------------------------------*/
//刷新Viewer
crystalReportViewer1.ReportSource = boReportDocument;
}
}
}