Load Crystal Report from Physical Path c#

using(CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new ReportDocument()) {
  var path =
    HttpContext.Current.Server.MapPath((@ "~/Reports/rptDatewiseSaleSummaryReport.rpt"));
  rd.Load(path);
  rd.SetDataSource(items);

  string fname = System.Web.HttpContext.Current.Server.MapPath("~/CReports") + "/" + guid.ToString() + "." + type;
  CrystalDecisions.Shared.DiskFileDestinationOptions dfo = new CrystalDecisions.Shared.DiskFileDestinationOptions();
  dfo.DiskFileName = fname;
  switch (type) {
  case "pdf":
    rd.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
    break;
  case "xls":
    rd.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;
    break;
  }
  rd.ExportOptions.DestinationOptions = dfo;
  rd.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;

  rd.Export();
  rd.Close();
}

Comments

Popular posts from this blog

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

JQuery UI Autocomplete, custom HTML structure for result?

Easy Ui Jquery easyui-textbox change onChange event