我需要在单个 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();
}
在我必须修改以生成多个报告的代码中?