我有一个 CheckBoxList。如果我选中了两个或更多的值,则会将 CheckBoxList SelectedValues 逐个作为参数传递,我想为每个 SelectedValue 生成一个 PDF 格式的 Crystal 报告,并将所有 Crystal 报告的 PDF 格式合并为单个 PDF 格式。如何实现这一点?
到目前为止,我只生成了一个 PDF 格式的 Crystal 报告。
以下是我如何生成 PDF 格式的 Crystal 报告的代码。
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
string[] str = conn.Split(';');
string server = str[0].Substring(str[0].IndexOf(" = ") + 3);
string database = str[1].Substring(str[1].IndexOf(" = ") + 3);
string userid = str[2].Substring(str[2].IndexOf(" = ") + 3);
string password = "Welc0me";//str[3].Substring(str[3].IndexOf(" = ") + 3);
rpt.Load(Server.MapPath(RepPath));
for (int i = 0; i < rpt.DataSourceConnections.Count; i++)
{
rpt.DataSourceConnections[i].SetConnection(server, database, userid, password);
}
// Here ReleaseID will be replaced by the CheckBoxList's SelectedValue
rpt.SetParameterValue(0, ReleaseID);
rpt.SetParameterValue(1, false);
rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
HttpContext.Current.Response, true, "Docs Report");
但是上面的代码只能一次生成单个pdf报告。但我想将每个CheckBoxList所选取的值作为参数传递。例如,如果我选择了三个值,则水晶报告应按照相应的SelectedValue一个接一个地包含所有三个水晶报告。 我该如何将所有PDF水晶报告合并为单个水晶报告?我必须解决这个问题。请帮助我。