【问题标题】:Multiple Report (Report will be same but Data/Calculation will be different) in a single RDLC report viewer单个 RDLC 报告查看器中的多个报告(报告将相同,但数据/计算将不同)
【发布时间】:2016-12-30 18:44:38
【问题描述】:

我需要在单个 RDLC 报告查看器中显示大量报告。我使用带有动态图像的 RDLC 报告生成了单个报告。但现在我需要生成相同的报告,但数据/计算会不同的多个数字。生成单个报告的代码如下。

rdlcTax.Visible = true;
rdlcTax.Reset();
rdlcTax.ProcessingMode = ProcessingMode.Local;
rdlcTax.LocalReport.DisplayName = "Tax" + dt.Rows[0]["NAME"].ToString();
rdlcTax.LocalReport.ReportPath = "Reports/rdlcTaxCertificate.rdlc";
ReportDataSource rds = new ReportDataSource("dsTaxCertificate", dt);
var param = new ReportParameter[] {
          new ReportParameter("fromDate", fromMonth.Replace("-", " ")),
          new ReportParameter("toDate", toMonth.Replace("-", " ")),
          new ReportParameter("rateOfDeduction", rateOfDeduction + "%"),
          new ReportParameter("name", name),
          new ReportParameter("address", address),
          new ReportParameter("refNo", refNo),
          new ReportParameter("issueDate", issueDate),
          new ReportParameter("amount", tdsSum.ToString("N", CultureInfo.InvariantCulture).Split('.')[0]),
          new ReportParameter("amountWord", textInfo.ToTitleCase(int.Parse(tdsSum.ToString()).ToText()) + " Taka Only"),
          new ReportParameter("imagePath", imagePath, true)
};

rdlcTax.LocalReport.EnableExternalImages = true;
rdlcTax.LocalReport.SetParameters(param);
rdlcTax.LocalReport.DataSources.Clear();
rdlcTax.LocalReport.DataSources.Add(rds);
rdlcTax.DataBind();
rdlcTax.LocalReport.Refresh();

我还尝试循环在同一个报表查看器中生成多个报表,但没有奏效。报告仅显示最后一个 DataTable 中的数据。代码如下。

rdlcTax.Visible = true;
rdlcTax.Reset();
rdlcTax.ProcessingMode = ProcessingMode.Local;
rdlcTax.LocalReport.DisplayName = "Tax Certificate";
rdlcTax.LocalReport.ReportPath = "Reports/rdlcTaxCertificateBulk.rdlc";
rdlcTax.LocalReport.EnableExternalImages = true;
rdlcTax.LocalReport.DataSources.Clear();
foreach (DataTable dt in ds.Tables)
{
     var name = dt.Rows[0]["NAME"].ToString();
     var address = dt.Rows[0]["ADDRESS"].ToString();
     var refNo = dt.Rows[0]["REFERENCE_NO"].ToString();
     var issueDate = dt.Rows[0]["ISSUE_DATE"].ToString();
     var tdsSum = Math.Round(double.Parse(dt.Compute("Sum(TDS_AMOUNT)", "").ToString()));

     ReportDataSource rds = new ReportDataSource("dsTaxCertificate", dt);
     var param = new ReportParameter[] {
            new ReportParameter("fromDate", fromMonth.Replace("-", " ")),
            new ReportParameter("toDate", toMonth.Replace("-", " ")),
                            new ReportParameter("rateOfDeduction", rateOfDeduction + "%"),
            new ReportParameter("name", name),
            new ReportParameter("address", address),
            new ReportParameter("refNo", refNo),
            new ReportParameter("issueDate", issueDate),
            new ReportParameter("amount", tdsSum.ToString("N", CultureInfo.InvariantCulture).Split('.')[0]),
            new ReportParameter("amountWord", textInfo.ToTitleCase(int.Parse(tdsSum.ToString()).ToText()) + " Taka Only"),
            new ReportParameter("imagePath", imagePath, true)
     };

     rdlcTax.LocalReport.SetParameters(param);
     rdlcTax.LocalReport.DataSources.Clear();
     rdlcTax.LocalReport.DataSources.Add(rds);
     rdlcTax.DataBind();
     rdlcTax.LocalReport.Refresh();
}

在我必须修改以生成多个报告的代码中?

【问题讨论】:

    标签: c# asp.net rdlc visual-studio-2017


    【解决方案1】:

    在您的批量报告中包含参数的目的是什么?这是基于你的代码sn-p喜欢理解的需求。

    您的表格中的所有列名称都相同吗?

    foreach (DataTable dt in ds.Tables)
    {
    ****
    }
    

    【讨论】:

    • 感谢您的回复。实际上我已经使用子报告解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多