private void Export(InitializeModule.ECT_Buttons iExport, List <Book> myCart) { ReportDocument myReport = new ReportDocument(); try { DataSet rptDS = new DataSet(); string reportPath = ""; rptDS = getBasket(myCart); reportPath = Server.MapPath("Reports/BooksBasket.rpt"); myReport.Load(reportPath); myReport.SetDataSource(rptDS); myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Page.Response, true, "ECTReport"); } catch (Exception ex) { Console.WriteLine("{0} Exception caught.", ex.Message); } finally { } }
private void Export(InitializeModule.ECT_Buttons iExport) { ReportDocument myReport = new ReportDocument(); try { if (Session["rptDS"] == null) { return; } DataSet rptDS = new DataSet(); rptDS = (DataSet)Session["rptDS"]; //Prepare_Report(Retrieve(iSession)); int iSession = Convert.ToInt32(rbnSession.SelectedValue); string reportPath = Server.MapPath("Reports/CurrentTimeTable_rpt.rpt"); myReport.Load(reportPath); myReport.SetDataSource(rptDS); TextObject txt; txt = (TextObject)myReport.ReportDefinition.ReportObjects["txtTitle"]; txt.Text = GetCaption(iSession); txt = (TextObject)myReport.ReportDefinition.ReportObjects["UserTXT"]; string sUserName = Session["CurrentUserName"].ToString(); txt.Text = "/ " + sUserName; switch (iExport) { case InitializeModule.ECT_Buttons.Print: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Page.Response, true, "ECTReport"); break; case InitializeModule.ECT_Buttons.ToExcel: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Page.Response, true, "ECTReport"); break; case InitializeModule.ECT_Buttons.ToWord: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.WordForWindows, Page.Response, true, "ECTReport"); break; } } catch (Exception exp) { Console.WriteLine("{0} Exception caught.", exp); //divMsg.InnerText = exp.Message; } finally { myReport.Close(); myReport.Dispose(); } }