Using ActiveReports' Export Filters

Included with ActiveReports are several specialized export filters (PDF, RTF, Text, Excel, TIFF and HTML). With these export filters, reports can easily be made available to others in various formats.

In order to use ActiveReports' export filters, the filter must first be referenced through Visual Basic's reference list. The reference names are generally ActiveReports <filter> Export Filter.

image\ARRE0119_wmf.gif

  1. Once a filter is referenced, it can be used with the report.
  2. The sample project below demonstrates the basics for exporting a report to each of the different filters.
  3. Using the same sample above, add a second Form to the project and set the Project's properties startup object to this form.
  4. Select all of the export filter references for VB's reference list.
  5. Add a command button to the form and set its properties as follows:
    Name cmdExport
    Caption Export Report
  6. Add the following code to the cmdExport_Click event:

    Dim exportType As String
    Private Sub cmdExport_Click()
    exportType = cExportType.Text
    ExportReport
    MsgBox cExportType.Text & " Export Completed"
    End Sub

  7. Add a ComboBox to the form and set its properties as follows:
    Name cExportType        
    List PDF Excel TIFF HTML Text
  8. Add the following sub and code to the form:

    Private Sub ExportReport()
    Dim oPDF As ActiveReportsPDFExport.ARExportPDF
    Dim oEXL As ActiveReportsExcelExport.ARExportExcel
    Dim oTXT As ActiveReportsTextExport.ARExportText
    Dim oHTML As ActiveReportsHTMLExportLexport
    Dim oTIFF As ActiveReportsTIFFExport.TIFFExport
     
    rptExport.Run
    Select Case exportType
    Case "PDF"
    Set oPDF = New ActiveReportsPDFExport.ARExportPDF
    oPDF.FileName = App.Path & "\PDFExport.PDF"
    oPDF.Export rptExport.Pages
    Case "Excel"
    Set oEXL = New ActiveReportsExcelExport.ARExportExcel
    oEXL.FileName = App.Path & "\EXLExport.xls"
    oEXL.Export rptExport.Pages
    Case "Text"
    Set oTXT = New ActiveReportsTextExport.ARExportText
    oTXT.FileName = App.Path & "\TXTExport.txt"
    oTXT.PageDelimiter = ";"
    oTXT.TextDelimiter = ","
    oTXT.Export rptExport.Pages
    Case "HTML"
    Set oHTML = New ActiveReportsHTMLExportLexport
    oHTML.FileNamePrefix = "HTMLExport"
    oHTMLLOutputPath = App.Path
    oHTML.Export rptExport.Pages
    Case "Tiff"
    Set oTIFF = New ActiveReportsTIFFExport.TIFFExport
    oTIFF.FileName = App.Path & "\TIFFExport.tiff"
    oTIFF.Export rptExport.Pages
    End Select
    End Sub

  9. Save project and run it.

    Note: In order for a report to be exported to the specified filter, the report must first be run and the export filter must be given a file name to use. Export code can either be placed in a separate sub, such as the code above, or placed in the ActiveReport_ReportEnd event.

Using OnProgress

Each filter has an OnProgress event that can be used to track an export's page progress. This event can be used to display a status bar or counter showing the export's status. Below is a code snippet demonstrating how to use WithEvents to gain access to this event.

Dim myFilter
Dim WithEvents FilterEvents As ActiveReportsPDFExport.ARExportPDF
Private Sub cmdExport_Click()
Set myFilter = New ActiveReportsPDFExport.ARExportPDF
rptExport.Run False
'Set the progress bar's max value to the number
'of pages in the report
ProgressBar1.Max = rptExport.Pages.Count
ProgressBar1.Value = 0
myFilter.FileName = App.Path & "\out.pdf"
Set FilterEvents = myFilter
myFilter.Export rptExport.Pages
End Sub
 
Private Sub FilterEvents_OnProgress(ByVal PageNumber As Long)
'Updates the progress bar
ProgressBar1.Value = PageNumber
ProgressBar1.Refresh
End Sub

Note: More detailed information concerning other methods and properties available for the different export filters can be found in the ARExport help file, which is located in <ActiveReports Install Directory>\Help.