|
导读在《简单实现Crystal Report动态加载》中,所提供的方法有时候并不能很好的工作。于是通过不断的实验和资料查询,终于发现了更好的方法。核心代码如下 CrystalDecisions.We... 在《简单实现Crystal Report动态加载》中,所提供的方法有时候并不能很好的工作。于是通过不断的实验和资料查询,终于发现了更好的方法。核心代码如下CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1; String path = Server.MapPath("./"); path = path + @"\Report\Report.rpt"; path = path.Replace("\\","\\\\"); ReportDocument Rep=new ReportDocument(); Rep.Load(path); DataSet ds = getDataSet(getConn()); Rep.SetDataSource(ds); CrystalReportViewer1.ReportSource = Rep; CrystalReportViewer1.DataBind(); 如上代码所示,这个方法通过ReportDocument类的Load()方法把报表模板加载入内存,利用推模式把DataSet数据推入模板。最后把这个ReportDocument绑定到CrystalReportViewer上。 |
温馨提示:喜欢本站的话,请收藏一下本站!