Question

I'm using Active Reports within my VB program to generate a report based on my data. Right now I have the report opening fine and it is allowing the user to print, copy, find, etc. I am unsure how to add the functionality to let the user choose to export the chart once the program is running.

I've been looking at many tutorials but there is always something that makes it unable to work in my program. For example this forum gives the exact code for what I want as they add an export button to the toolbar and then adds the functionality to the button. Unfortunately I am unable to access the toolbar. They access it with Me.Toolbar and I am unable to access it this way.

Another forum here doesn't add the export to the toolbar and instead inserts it directly into the code but I'm not sure what to import to allow me to do it this way as my project doesn't recognize ActiveReportsPDFExport.ARExportPDF.

UPDATE:

Found a way to export to PDF by adding to the ActiveReport in the design format a DataDynamics.ActiveReports.Export.Pdf.PdfExport and then calling from my code PdfExport1.Export(Me.Document, "D:\Kyra\HELP.pdf")

Problem:

  1. This is called at the end of my function which opens the active report. I want the user to be able to choose to export the report and then be given the option of choosing the format and location where they want to save the report to.
Was it helpful?

Solution

Below is the code to add a PDF Export button to the ActiveReports Toolbar using VB.NET and ActiveReports 6:

Const pdfExportToolID As Long = 42

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim myExportTool As DataDynamics.ActiveReports.Toolbar.Button
    myExportTool = New DataDynamics.ActiveReports.Toolbar.Button()
    myExportTool.ButtonStyle = DataDynamics.ActiveReports.Toolbar.ButtonStyle.Text
    myExportTool.Caption = "Export to PDF"
    myExportTool.Id = pdfExportToolID
    Me.Viewer1.Toolbar.Tools.Add(myExportTool)

    ' load report:
    Dim rpt As New NewActiveReport1()
    Me.Viewer1.Document = rpt.Document
    rpt.Run(False)
End Sub

Private Sub Viewer1_ToolClick(ByVal sender As System.Object, ByVal e As DataDynamics.ActiveReports.Toolbar.ToolClickEventArgs) Handles Viewer1.ToolClick
    If (e.Tool.Id = pdfExportToolID) Then
        Dim pdf As New DataDynamics.ActiveReports.Export.Pdf.PdfExport()
        pdf.Export(Me.Viewer1.Document, "C:\users\scott\junk\myActiveReport.pdf")

    End If
End Sub

This code works inside of a form with an ActiveReports Viewer on hte form named "Viewer1".

Hope this helps,

Scott Willeke
GrapeCity

OTHER TIPS

Just follow along in the instructions here. Specifically, it's the button they add 'cmdExport' that lets the user start the export.

This code working for me, just pass it Webviewer object.

ABC.Run();
ARWebViewer.Report = ABC; 

ExportToExcel(ARWebViewer); // call ExportToExcel method, 

public void ExportToExcel(DataDynamics.ActiveReports.Web.WebViewer objWebviewer)

    {
        DataDynamics.ActiveReports.Export.Xls.XlsExport XLSexport = new DataDynamics.ActiveReports.Export.Xls.XlsExport();

        System.IO.MemoryStream memStream = new System.IO.MemoryStream();
        if (XLSexport == null)
            XLSexport = new DataDynamics.ActiveReports.Export.Xls.XlsExport();

        XLSexport.AutoRowHeight = true;
        XLSexport.MinColumnWidth = (float)0.2;
        XLSexport.RemoveVerticalSpace = true;
        XLSexport.UseCellMerging = true;

        XLSexport.Export(objWebviewer.Report.Document, memStream);
        memStream.Position = 0;
        Response.ContentType = "application/Xls";
        Response.AddHeader("content-disposition", "attachment; filename=" + ajDoc + ".Xls");

        Response.BinaryWrite(memStream.ToArray());
        Response.End();
        XLSexport = null;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top