|
The following guidelines show how to use ActiveReports 2.0 under the .NET framework. - Launch Visual Basic 6.0 and create a new ActiveX DLL project.
- Click on the Class1 module in the Project Explorer window and use the Properties window to change the name of the class to Exporter.
- Click on the Project1 project in the Project Explorer window, and use the Properties window to change the name of the project to AR_Provider.
- Add a new Data Dynamics ActiveReports 2.0 ActiveX report to the project, and use the Properties window to change the name of the report to Rpt.
- Add a new Label control in the report’s layout.
- Set the caption property of the label control to “ActiveReports test”.
- Add a reference to the ActiveReports PDF Export Filter to the project.
- Add this code to the Exporter class:
Option Explicit
Public Function PDFExport() As Byte() Dim ar As New Rpt Dim exp As New ActiveReportsPDFExport.ARExportPDF Dim st As Variant ar.Run False exp.ExportStream ar.Pages, st PDFExport = st End Function - Save the project.
- Open the File menu and choose Make AR_Provider.dll
To install this COM component on your Visual Studio .NET computer: - Create a new folder named AR_Provider on your hard drive.
- Copy AR_Provider.dll to the AR_Provider folder.
- Open a command prompt window and type:
regsvr32 c:\ AR_Provider\AR_Provider.dll Use TLBIMP to Create an Assembly Next, use the tlbimp utility to create an assembly that provides a Wrapper for the AR_Provider component. - To open a Visual Studio .NET command prompt window, click Start > Programs > Microsoft Visual Studio .NET 7.0\2002\2003\2005 > Visual Studio .NET Tools > Visual Studio .NET Command Prompt.
- Change to the \AR_Provider directory.
- At the command prompt, type:
tlbimp AR_Provider.dll /out:NETAR_Provider.dll Create the Test Project Now you can test the ability of a Visual Basic .NET application to use an object from a legacy COM component. - Open Visual Studio .NET and, from the Start page, choose New Project.
- Select Visual Basic Project from the tree view on the left side of the screen.
- Select Windows Application as the project template.
- Set the name of the application to AR_ProviderTest and click OK to create the project.
- Highlight the form called Form1.vb in the Solution Explorer window and rename it to frmAR_Provider .vb.
- Open the Project menu, and choose Add Reference. Make sure that the .NET tab is selected, and click Browse.
- Browse to the AR_Provider folder and select the NET AR_Provider.dll component. Click Open.
- Double click on the frm AR_Provider and add this code:
Private Sub frm AR_Provider _Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim rpt As New NETAR_Provider.Exporter Dim fs As IO.FileStream Dim f As IO.File fs = f.Create("c:\test.pdf") fs.Write(rpt.PDFexport, 0, rpt.PDFExport.Length) fs.Close() System.Diagnostics.Process.Start("c:\test.pdf") End Sub - Press F5 to start the project.
You will see an Acrobat Reader window with the exported Active Reports 2.0 report.
Applies To: ActiveReports 2.0
|