我是新的Asp.net mvc在Crystal报告中生成子报告。请给出任何建议。 在这里,我附加了我在ASP.NET MVC中生成Crystal Report的编码。但我需要在Crystol报告中生成子报告 下面是我的单一报告生成编码:
public ActionResult EmployeeExpensesReport()
{
SqlConnection conn = new SqlConnection(@"data source=192.168.0.73\SQLEXPRESS,14330;initial catalog=WafeERP_NEW;user id=sa;password=wafewin;");
DataTable dt = new DataTable();
try
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from view_TollGate", conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
catch (Exception ex)
{
throw;
}
ReportClass RC = new ReportClass();
RC.FileName = Server.MapPath("rpt_EmployeeExpensesReport.rpt");
RC.Load();
RC.SetDataSource(dt);
Stream stream = RC.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
}
这里我只添加了tollgate数据表,但我需要在setdatasource中添加多个数据表。
答案 0 :(得分:0)
您没有“在MVC中生成子报告”,您将主报告设计为包含绑定到数据集各部分的子报告,这些子报告可能形成层次结构。
将xml视为带有子元素的元素。子报告将绑定到这些子元素。这是在Crystal设计器中完成的,然后它将在ASP.NET中显示子报告