我有一个我已经建立的应用程序,并且正在尝试使用我从控制器中查询的内容来整合水晶报告
这是报告生成器控制器
public ActionResult ExportReport(int CategoryId, string DateFrom, string DateTo)
{
DateTime StartDate = Convert.ToDateTime(DateFrom);
DateTime EndDate = Convert.ToDateTime(DateTo);
ReportDocument read = new ReportDocument();
if (CategoryId == 1)
{
var dailyReport = _routineService.GetAllRoutines().Where(x => x.LaodingDate >= StartDate && x.LaodingDate <= EndDate && x.CategoryId == CategoryId).ToList();
read.Load(Path.Combine(Server.MapPath("~/Reports"), "DailyReport.rpt"));
read.SetDataSource(dailyReport);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
try
{
Stream stream = read.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "Enugu_Local_DailySalesReport.pdf");
}
catch (Exception ex)
{
throw ex;
}
}
else if (CategoryId == 2)
{
var bridgReport = _routineService.GetAllRoutinesByCategory(CategoryId).Where(x => x.LaodingDate >= StartDate && x.LaodingDate <= EndDate).ToList();
read.Load(Path.Combine(Server.MapPath("~/Reports"), "BridgingDailyReport.rpt"));
read.SetDataSource(bridgReport);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
try
{
Stream stream = read.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "Enugu_Bridging_DailySalesReport.pdf");
}
catch (Exception ex)
{
throw ex;
}
}
return RedirectToAction("DailyReport");
}
现在的问题是,当数据库使用该特定数据进行查询时,而不是Crystal报表模板来打印从数据库中查询的内容,它现在可以从数据库中提取每条记录,而不管日期和类别...我不知道#39; t想要数据库中的每条记录,我想打印每日,每月,每季度和每年的报告。
我认为有些原因是因为我将水晶报告直接连接到这样的数据库。\ sqlexpress。我怎样才能使它与我的查询一起工作?
我需要一些关于如何将我从数据库查询的内容导出到水晶报告的帮助
我是水晶报告的新手请帮帮我谢谢