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
Post a Comment