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.
Name | cmdExport |
---|---|
Caption | Export Report |
Dim exportType As String
Private Sub cmdExport_Click()
exportType = cExportType.Text
ExportReport
MsgBox cExportType.Text & " Export Completed"
End Sub
Name | cExportType | ||||
---|---|---|---|---|---|
List | Excel | TIFF | HTML | Text |
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
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.
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.