2

我正在尝试在我一直从事的项目中使用 Crystal Reports。我对 Crystal Reports 没有太多经验,但从我在网上搜索的内容来看,到目前为止,我已经完成了这段代码:

标记:

 <CR:CrystalReportViewer ID="crViewerReports" Visible="true"  runat="server" 
            AutoDataBind="true" ReportSourceID="crs" />
       <CR:CrystalReportSource ID="crs" runat="server" >
           <Report FileName="MyReport.rpt">
           </Report>
       </CR:CrystalReportSource>

代码:

  DataSet ds = new DataSet();
            ds = util.getReportDataSet(DateTime.Now.AddYears(-5), DateTime.Now, 100,4, null);

Crystal Reports 文件来自其他应用程序并且工作正常我只需要获取数据集。

4

2 回答 2

0

下一步是将报表的数据源分配给刚刚加载的数据集:

crs.ReportDocument.SetDataSource(ds);

如果你有参数,你还需要设置它们

于 2013-03-28T23:49:46.397 回答
0

这是 aspx :

 <updatepanel id="up" updatemode="alwayz"> 
<ContentTemplate>
    <CR:CrystalReportViewer ID="crvReportParameter" runat="server" Visible="false" EnableParameterPrompt="false"
                ReuseParameterValuesOnRefresh="true" ToolPanelView="None" AutoDataBind="true"
                HasCrystalLogo="False" HasToggleParameterPanelButton="false" />
</ContentTemplate>
</updatepanel>

这是 CS 文件:

ds = util.getReportDataSet(DateTime.Now.AddYears(-5), DateTime.Now, 100,4, null);
                            rptDoc.Load(Server.MapPath(""MyReport.rpt""));

        rptDoc.SetDataSource(dsData.Tables[0]);
     crvReportParameter.ReportSource = rptDoc;
                crvReportParameter.DataBind();
于 2013-04-09T05:29:56.740 回答