See the code sample:
public ActionResult GenerateReport(CustomerPackageReportViewModel CustomerPackageReportViewModel)
{
List<CustomerPackageDetailsReportViewModel> _customerList = (List<CustomerPackageDetailsReportViewModel>)Session["CustomerPackageInfo"];
DataTable tableObj = new DataTable();
if (_customerList!=null)
{
tableObj = Converter.ToDataTable(_customerList);
}
else
{
tableObj = Converter.ToDataTable(ArchitectureList);
}
ReportDocument reportDoc = new ReportDocument();
string rptPath = "";
rptPath = Server.MapPath("~/Reports/Billing/Crystal/rptCustomerPackage.rpt");
reportDoc.Load(rptPath);
reportDoc.SetDataSource(tableObj);
Stream reportStream = this.ConvertReportToPDF(reportDoc);
return new FileStreamResult(reportStream, "application/pdf");
}
[NonAction]
public Stream ConvertReportToPDF(ReportDocument DocReport)
{
if (DocReport == null)
{
return null;
}
return DocReport.ExportToStream(ExportFormatType.PortableDocFormat);
}
Comments
Post a Comment