public ActionResult Export(ExportModel model) { XtraReport report = new ProductsReport(); string fileName = String.Format("Report.{0}", model.Format); using (MemoryStream ms = new MemoryStream()) { switch (model.Format) { case "pdf": report.ExportToPdf(ms); break; case "docx": report.ExportToDocx(ms); break; case "xls": report.ExportToXls(ms); break; case "xlsx": report.ExportToXlsx(ms); break; case "rtf": report.ExportToRtf(ms); break; case "mht": report.ExportToMht(ms); break; case "html": report.ExportToHtml(ms); break; case "txt": report.ExportToText(ms); break; case "csv": report.ExportToCsv(ms); break; case "png": report.ExportToImage(ms, new ImageExportOptions() { Format = System.Drawing.Imaging.ImageFormat.Png }); break; } return(ExportDocument(ms.ToArray(), model.Format, fileName, false)); } }
public ActionResult Print() { XtraReport report = new ProductsReport(); using (MemoryStream ms = new MemoryStream()) { report.ExportToPdf(ms, new PdfExportOptions() { ShowPrintDialogOnOpen = true }); return(ExportDocument(ms.ToArray(), "pdf", "Report.pdf", true)); } }