protected override object OnCreateReportHandler(string reportPath) { var data = reportPath.Split(';'); if (data.Length != 2) { return(base.OnCreateReportHandler(reportPath)); } switch (data[0]) { case "Section": var sectionReport = new SectionReport(); sectionReport.LoadLayout(XmlReader.Create(Server.MapPath("~/Reports/OrderReport.rpx"))); sectionReport.DataSource = Repository.GetOrders(data[1]); var xvalues = new List <string>(); var yvalues = new List <double>(); foreach (Order order in Repository.GetOrders(data[1])) { xvalues.Add(order.ShippedDate); yvalues.Add((double)order.Freight); } ((SectionReportModel.ChartControl)sectionReport.Sections["reportFooter1"].Controls[0]).Series[0].Points.DataBindXY(xvalues.ToArray(), yvalues.ToArray()); return(sectionReport); case "Page": var pageReport = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx"))); pageReport.Document.LocateDataSource += delegate(object sender, LocateDataSourceEventArgs args) { args.Data = Repository.GetDetails(data[1]); }; return(pageReport); } return(base.OnCreateReportHandler(reportPath)); }
protected override object OnCreateReportHandler(string reportPath) { SectionReport rptOrders; switch (reportPath) { case "Reports/BillingInvoice.rdlx": case "Reports/Orders.rdlx": PageReport rptPageRDL = new PageReport(); rptPageRDL.Load(new FileInfo(Server.MapPath(reportPath))); rptPageRDL.Report.DataSources[0].ConnectionProperties.ConnectString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;"; return(rptPageRDL); case "Reports/Invoice.rpx": rptOrders = new SectionReport(); XmlTextReader xtr = new XmlTextReader(Server.MapPath(reportPath)); rptOrders.LoadLayout(xtr); (rptOrders.DataSource as OleDBDataSource).ConnectionString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;"; return(rptOrders); default: return(base.OnCreateReportHandler(reportPath)); } }
void LoadReport(ReportType reportType) { // Instantiate a new Invoice report var report = new SectionReport(); report.LoadLayout(XmlReader.Create(Properties.Resources.Invoice)); report.MaxPages = 10; // Set the connection string to the sample database. ((OleDBDataSource)report.DataSource).ConnectionString = Properties.Resources.ConnectionString; switch (reportType) { case ReportType.CrossSectionControls: cscViewer.LoadDocument(report); break; case ReportType.RepeatToFill: ((Detail)report.Sections["Detail"]).RepeatToFill = true; repeatToFillViewer.LoadDocument(report); break; case ReportType.PrintAtBottom: ((GroupFooter)report.Sections["customerGroupFooter"]).PrintAtBottom = true; printAtBottomViewer.LoadDocument(report); break; } }
/// <summary> /// Handles the hyperlink sent from the viewer object. /// </summary> private void arvMain_HyperLink(object sender, GrapeCity.ActiveReports.Viewer.Win.HyperLinkEventArgs e) { e.Handled = true; string hyperlink = e.HyperLink.Split(':')[1]; string report = e.HyperLink.Split(':')[0]; if (report == "DrillThrough1") { // Click on customer ID to open the drill through for that customer. var rpt2 = new SectionReport(); rpt2.LoadLayout(XmlReader.Create(Properties.Resources.DrillThrough1)); ViewerMain frm2 = new ViewerMain(false); rpt2.Parameters["customerID"].Value = hyperlink; frm2.arvMain.LoadDocument(rpt2); frm2.ShowDialog(this); } else if (report == "DrillThrough2") { // Click order number to open the order details var rpt3 = new SectionReport(); rpt3.LoadLayout(XmlReader.Create(Properties.Resources.DrillThrough2)); ViewerMain frm3 = new ViewerMain(false); rpt3.Parameters["orderID"].Value = hyperlink; frm3.arvMain.LoadDocument(rpt3); frm3.ShowDialog(this); } }
private void RunReport_DSRelations() { // ***** Sub report using the data set that contains the relationship ***** DataSet myJoinedDS = new DataSet(); var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptDSRelationParent)); string cnnString = Properties.Resources.ConnectionString; OleDbConnection cnn = new OleDbConnection(cnnString); cnn.Open(); OleDbDataAdapter catAd = new OleDbDataAdapter("Select * from categories order by categoryname", cnn); OleDbDataAdapter prodAd = new OleDbDataAdapter("Select * from products order by productname", cnn); OleDbDataAdapter ODAd = new OleDbDataAdapter("Select * from [order details]", cnn); //Add three DataTables in the DataSet (myJoinedDS) catAd.Fill(myJoinedDS, "Categories"); prodAd.Fill(myJoinedDS, "Products"); ODAd.Fill(myJoinedDS, "OrderDetails"); cnn.Close(); //Sets the parent-child relationship between DataTable. myJoinedDS.Relations.Add("CategoriesProducts", myJoinedDS.Tables["Categories"].Columns["CategoryID"], myJoinedDS.Tables["Products"].Columns["CategoryID"]); myJoinedDS.Relations.Add("ProductsOrderDetails", myJoinedDS.Tables["Products"].Columns["ProductID"], myJoinedDS.Tables["OrderDetails"].Columns["ProductID"]); rpt.DataSource = (myJoinedDS); rpt.DataMember = "Categories"; arvMain.LoadDocument(rpt); }
/// <summary> /// btnCustomersLeveled_Click - Creates a OrdersLeveled report and sets /// the data source for it. /// </summary> private void btnCustomersLeveled_Click(object sender, EventArgs e) { try { //OrdersLeveled rpt = new OrdersLeveled(); var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.OrdersLeveled)); Data.XMLDataSource ds = rpt.DataSource as Data.XMLDataSource; if (ds == null) { // Display the message when an error occurs. MessageBox.Show(Properties.Resources.DataSourceError, this.Text); return; } // Set the XML file name. ds.FileURL = Properties.Resources.ConnectionString; // Display the report. ViewerForm frm = new ViewerForm(); frm.Show(); frm.LoadReport(rpt); } catch (ReportException ex) { MessageBox.Show(ex.ToString(), Text); } }
private void RunReport_UnboundDataSet() { // ***** To view the DataSet with multiple tables using sub-reports ***** // To generate dataset using "Customers" and "Orders" tables. OleDbConnection nwindConn = new OleDbConnection(Properties.Resources.ConnectionString); OleDbCommand selectCMD = new OleDbCommand("SELECT * FROM Customers", nwindConn); selectCMD.CommandTimeout = 30; OleDbCommand selectCMD2 = new OleDbCommand("SELECT * FROM Orders", nwindConn); selectCMD2.CommandTimeout = 30; OleDbDataAdapter custDA = new OleDbDataAdapter(); custDA.SelectCommand = selectCMD; OleDbDataAdapter ordersDA = new OleDbDataAdapter(); ordersDA.SelectCommand = selectCMD2; DataSet DS = new DataSet(); custDA.Fill(DS, "Customers"); ordersDA.Fill(DS, "Orders"); nwindConn.Close(); var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptUnboundDSMain)); rpt.DataSource = DS; rpt.DataMember = "Customers"; arvMain.LoadDocument(rpt); }
private void btnReport_Click(object sender, EventArgs e) { SectionReport rpt = new SectionReport(); try { //Display the preview according to the "chart type" combobox. switch (cboStyle.SelectedIndex) { case 0: // 2D bar chart rpt.LoadLayout(XmlReader.Create(Properties.Resources.rpt2DBar)); break; case 1: // 3D pie chart rpt.LoadLayout(XmlReader.Create(Properties.Resources.rpt3DPie)); //Set the direction of rotation. if (cboCustom.SelectedIndex == 0) { ((ChartControl)(rpt.Sections["Detail"].Controls["ChartSalesCategories"])).Series[0].Properties["Clockwise"] = true; } else { ((ChartControl)(rpt.Sections["Detail"].Controls["ChartSalesCategories"])).Series[0].Properties["Clockwise"] = false; } break; case 2: //3D bar chart rpt.LoadLayout(XmlReader.Create(Properties.Resources.rpt3DBar)); break; case 3: // Finance chart rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptCandle)); break; case 4: // Stacked area chart rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptStackedArea)); break; } arvMain.LoadDocument(rpt ?? new SectionReport()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void RunReport_Bookmark() { // ***** Bookmark in sub-report ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptBookmarkMain)); arvMain.LoadDocument(rpt); }
private void exportButton_Click(object sender, EventArgs e) { var reportName = (string)reportsNames.SelectedItem; var exportType = (string)exportTypes.SelectedItem; IDocumentExportEx documentExportEx = null; var report = new SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(@"..\..\..\..\Reports\" + reportName); report.LoadLayout(xtr); report.Run(); var exporTypeLower = exportType.ToLower(); switch (exporTypeLower) { case _pdf: documentExportEx = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); break; case _xlsx: documentExportEx = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport() { FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx }; break; case _rtf: documentExportEx = new GrapeCity.ActiveReports.Export.Word.Section.RtfExport(); break; case _mht: documentExportEx = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport(); break; case _csv: documentExportEx = new GrapeCity.ActiveReports.Export.Xml.Section.TextExport(); break; } var fileName = Path.GetFileNameWithoutExtension(reportName); var saveFileDialog = new SaveFileDialog() { FileName = fileName + GetSaveDialogExtension(exporTypeLower), Filter = GetSaveDialogFilter(exporTypeLower) }; if (saveFileDialog.ShowDialog() != DialogResult.OK) { return; } exportButton.Enabled = false; using (var stream = new FileStream(Path.Combine(saveFileDialog.FileName), FileMode.Create)) documentExportEx.Export(report.Document, stream); exportButton.Enabled = true; }
/// <summary> /// btnArray_Click - Illustrates using a Array as a data source /// </summary> private void btnArray_Click(object sender, System.EventArgs e) { //Create the report var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.UnboundDAInvoice)); //Run and view the report arvMain.LoadDocument(rpt); }
private void Button_Click(object sender, EventArgs e) { var rpt = new SectionReport(); var reportPath = "..\\..\\" + (string)comboBox1.SelectedItem; rpt.LoadLayout(XmlReader.Create(reportPath)); rpt.PrintWidth = 6.5F; arvMain.LoadDocument(rpt); }
// Define a structure for LINQtoObject. private void ViewerForm_Load(object sender, EventArgs e) { // To generate a report. var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create("..\\..\\rptLINQtoObject.rpx")); // To run the report. arvMain.LoadDocument(rpt); }
/// <summary> /// ViewerForm_Load - Handles initial form setup. /// </summary> private void ViewerForm_Load(object sender, EventArgs e) { if (_loadMainReport) { var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.DrillThroughMain)); arvMain.LoadDocument(rpt); } }
private void RunReport_Parameter() { // ***** Use a parameter in the subreport ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptParamMain)); arvMain.LoadDocument(rpt); }
private void RunReport_Simple() { // ***** Simple sub-report ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptSimpleMain)); arvMain.LoadDocument(rpt); }
private void RunReport_Hierarchical() { // *****Hierarchical structure of sub-reports ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptHierarchicalMain)); arvMain.LoadDocument(rpt); }
private void RunReport_Nested() { // ***** Nested sub-reports ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptNestedParent)); arvMain.LoadDocument(rpt); }
private void RunReport_MasterSubreport() { // ***** Master-detail report contains a subreport ***** var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptMasterMain)); arvMain.LoadDocument(rpt); }
protected void Page_Load(object sender, EventArgs e) { SectionReport rpt = new SectionReport(); var reportsPath = Path.Combine(Server.MapPath("~"), "Reports") + @"\"; rpt.ResourceLocator = new DefaultResourceLocator(new Uri(reportsPath)); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Path.Combine(reportsPath, "Invoice.rpx")); rpt.LoadLayout(xtr); xtr.Close(); try { rpt.Run(false); } catch (ReportException eRunReport) { // Failure running report, just report the error to the user. Response.Clear(); Response.Write(GetLocalResourceObject("Error")); Response.Write(eRunReport.ToString()); return; } // Tell the browser this is a PDF document so it will use an appropriate viewer. // If the report has been exported in a different format, the content-type will // need to be changed as noted in the following table: // ExportType ContentType // PDF "application/pdf" (needs to be in lowercase) // RTF "application/rtf" // TIFF "image/tiff" (will open in separate viewer instead of browser) // HTML "message/rfc822" (only applies to compressed HTML pages that includes images) // Excel "application/vnd.ms-excel" // Excel "application/excel" (either of these types should work) // Text "text/plain" Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF"); // Create the PDF export object. PdfExport pdf = new PdfExport(); // Create a new memory stream that will hold the pdf output. System.IO.MemoryStream memStream = new System.IO.MemoryStream(); // Export the report to PDF. pdf.Export(rpt.Document, memStream); // Write the PDF stream to the output stream. Response.BinaryWrite(memStream.ToArray()); // Send all buffered content to the client. Response.End(); }
//Getting the Designer to Export the Report on Menu Item "Export" click private void OnExport(object sender, EventArgs e) { if (ConfirmSaveChanges()) { fileName = SaveFile("pdf files|*.pdf", ".pdf"); SectionReport rpt = new SectionReport(); XmlTextReader xtr = new XmlTextReader(reportName); rpt.LoadLayout(xtr); rpt.Run(); Export.Pdf.Section.PdfExport PdfExport1 = new Export.Pdf.Section.PdfExport(); PdfExport1.Export(rpt.Document, fileName); System.Diagnostics.Process.Start(fileName); } }
/// <summary> /// btnGenerateReport_Click - Opens a new viewer form to display the /// report bound to the DataLayer object /// </summary> private void btnGenerateReport_Click(object sender, System.EventArgs e) { // Create new report object var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create("IlistReportSample.rpx")); rpt.DataSource = _productCollection; // Pass the document to show in the viewer form ViewerForm frmViewer = new ViewerForm(); frmViewer.Show(); frmViewer.LoadDocument(rpt); }
private void StartForm_Load(object sender, EventArgs e) { try { //Create a report and display it in the Viewer. var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.ProductWeeklySales)); arvMain.LoadDocument(rpt); } catch (Exception ex) { //Display a message when an error is thrown while creating a report. MessageBox.Show(ex.ToString(), Text); } }
void RunSectionReport() { MemoryStream memoryStream = new MemoryStream(); memoryStream.Position = 0; using (XmlWriter writer = XmlWriter.Create(memoryStream)) { ((SectionReport)_report).SaveLayout(writer); } memoryStream.Position = 0; using (XmlReader reader = XmlReader.Create(memoryStream)) { _sectionReport.LoadLayout(reader); } _sectionReport.Run(); }
public void ProcessRequest(HttpContext context) { if (!context.Request.Url.AbsolutePath.EndsWith(HandlerExtension)) { if (!context.Request.Url.AbsolutePath.EndsWith(HandlerCacheExtension)) { return; } // return image var keyName = Path.GetFileName(context.Request.FilePath); var cacheItem = context.Cache[keyName]; context.Response.BinaryWrite((byte[])cacheItem); return; } var rpxFile = context.Server.MapPath(context.Request.Url.LocalPath); var htmlHandler = new HtmlOutputHandler(context.Cache, Path.GetFileNameWithoutExtension(rpxFile)); context.Response.ContentType = "text/html"; try { using (var report = new SectionReport()) using (var reader = XmlReader.Create(rpxFile)) { report.ResourceLocator = new DefaultResourceLocator(new Uri(Path.GetDirectoryName(rpxFile) + @"\")); report.LoadLayout(reader); report.Run(false); using (var html = new HtmlExport { IncludeHtmlHeader = true }) html.Export(report.Document, htmlHandler, ""); report.Document.Dispose(); } } catch (ReportException eRunReport) { // Failure running report, just report the error to the user. context.Response.Write(Properties.Resource.Error); context.Response.Write(eRunReport.ToString()); return; } context.Response.BinaryWrite(htmlHandler.MainPageData); }
/// <summary> /// PrintMultiplePagesPerSheetForm_Load: Run the sample report and load it into the viewer control (first 20 pages - report normally runs to 100 pages). /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PrintMultiplePagesPerSheetForm_Load(object sender, EventArgs e) { //Define and run the Invoice report var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.Invoice)); ((Data.OleDBDataSource)rpt.DataSource).ConnectionString = Properties.Resources.ConnectionString; rpt.Run(false); //Remove all but the first 20 pages from the generated report. while (rpt.Document.Pages.Count > 20) { rpt.Document.Pages.RemoveAt(rpt.Document.Pages.Count - 1); } arViewer.Document = rpt.Document; apiViewer.Document = rpt.Document; // Find the maximum page size. PagesCollection pages = arViewer.Document.Pages; Page page; _pageCount = pages.Count; for (int pageIndex = 0; pageIndex < _pageCount; pageIndex++) { page = pages[pageIndex]; if (_maxPageSize.Width < page.Size.Width) { _maxPageSize.Width = page.Size.Width; } if (_maxPageSize.Height < page.Size.Height) { _maxPageSize.Height = page.Size.Height; } } // Convert to document units. _maxPageSize.Width *= 100; _maxPageSize.Height *= 100; cmbPageCount.SelectedIndex = cmbPageCountAPI.SelectedIndex = 0; }
/// <summary> /// btnCustomers_Click - Checks the radio options and sets the report object's data /// </summary> private void btnCustomers_Click(object sender, EventArgs e) { try { var rpt = new SectionReport(); rpt.LoadLayout(XmlReader.Create(Properties.Resources.CustomersOrders)); Data.XMLDataSource ds = rpt.DataSource as Data.XMLDataSource; if (ds == null) { // Display the message when an error occurs. MessageBox.Show(Properties.Resources.DataSourceError, this.Text); return; } ds.FileURL = Properties.Resources.ConnectionString; // Set an XSL pattern to get the node (record) based on the report. if (radioAll.Checked) { // Show all data ds.RecordsetPattern = "//CUSTOMER"; } else if (radioID.Checked) { // Show data where ID = 2301 ds.RecordsetPattern = "//CUSTOMER[@id = " + @"""" + "2301" + @"""" + "]"; } else if (radioEmail.Checked) { // Show data where Email is valid ds.RecordsetPattern = "//CUSTOMER[@email]"; } ViewerForm frm = new ViewerForm(); frm.Show(); frm.LoadReport(rpt); } catch (ReportException ex) { MessageBox.Show(ex.ToString(), Text); } }
private void buttonRunReport_Click(object sender, EventArgs e) { XmlReader xmlReader = null; // Select the report in the Viewer. // if (radioButtonProductListReport.Checked) { xmlReader = XmlReader.Create(Properties.Resources.ProductsReport); } else if (radioButtonCategoriesReport.Checked) { xmlReader = XmlReader.Create(Properties.Resources.CategoryReport); } var report = new SectionReport(); report.LoadLayout(xmlReader); // Apply stylesheet on the report. // string outputFolder = new FileInfo(GetType().Assembly.Location).DirectoryName + "\\"; string styleSheet = ""; if (radioButtonClassicStyle.Checked) { styleSheet = outputFolder + "Classic.reportstyle"; } else if (radioButtonColoredStyle.Checked) { styleSheet = outputFolder + "Colored.reportstyle"; } else if (_externalStyleSheet != "") { styleSheet = _externalStyleSheet; } if (styleSheet != "") { report.LoadStyles(styleSheet); } reportViewer.LoadDocument(report); }
protected void Page_Load(object sender, EventArgs e) { SectionReport rpt = new SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\NwindLabels.rpx"); rpt.LoadLayout(xtr); xtr.Close(); try { rpt.Run(false); } catch (ReportException eRunReport) { // Show error message to the user when there is a failure in generating the report. Response.Clear(); Response.Write("<h1>Error running report:</h1>"); Response.Write(eRunReport.ToString()); return; } // Used when the page output is already getting created. Response.Buffer = true; // Clear the output contents from the buffer stream. Response.ClearContent(); // Clear any headers from the buffer stream (such as the content type for an HTML page). Response.ClearHeaders(); // Notify the browser that cache should not be created. Response.Cache.SetCacheability(HttpCacheability.NoCache); // Specify the appropriate viewer for the browser. Response.ContentType = "text/html"; // Create an instance of the HTMLExport class. HtmlExport html = new HtmlExport { IncludeHtmlHeader = true }; // Export the report to HTML in this session's webcache. RpxHandler.HtmlOutputHandler output = new RpxHandler.HtmlOutputHandler(Cache, "Custom HTML"); html.Export(rpt.Document, output, string.Empty); Response.BinaryWrite(output.MainPageData); // Send all buffered content to the client Response.End(); }
protected void Page_Load(object sender, EventArgs e) { // Load the report layout System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\Params.rpx"); _rpt.LoadLayout(xtr); xtr.Close(); if (!IsPostBack) { // Sets the combo box. cboViewerType.Items.Clear(); cboViewerType.Items.Add("HTML"); cboViewerType.Items.Add("Flash"); cboViewerType.Items.Add("AcrobatReader"); cboViewerType.Items.Add("RawHtml"); // The default is set to HTML viewer. cboViewerType.SelectedIndex = 0; DateTime InitDate = new DateTime(1994, 9, 2); Calendar1.VisibleDate = InitDate; } _rpt.Restart(); WebViewer1.Report = _rpt; Session["Report"] = _rpt; }