Print Search Rate
    
   08-01-2005, 7:03 AM
How Can I Use ActiveReports 2.0 in Visual Studio .NET?

The following guidelines show how to use ActiveReports 2.0 under the .NET framework.

  1. Launch Visual Basic 6.0 and create a new ActiveX DLL project.
  2. Click on the Class1 module in the Project Explorer window and use the Properties window to change the name of the class to Exporter.
  3. 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.
  4. 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.
  5. Add a new Label control in the report’s layout.
  6. Set the caption property of the label control to “ActiveReports test”.
  7. Add a reference to the ActiveReports PDF Export Filter to the project.
  8. 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
  9. Save the project.
  10. Open the File menu and choose Make AR_Provider.dll

To install this COM component on your Visual Studio .NET computer:

  1. Create a new folder named AR_Provider on your hard drive.
  2. Copy AR_Provider.dll to the AR_Provider folder.
  3. 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.

  1. 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.
  2. Change to the \AR_Provider directory.
  3. 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.

  1. Open Visual Studio .NET and, from the Start page, choose New Project.
  2. Select Visual Basic Project from the tree view on the left side of the screen.
  3. Select Windows Application as the project template.
  4. Set the name of the application to AR_ProviderTest and click OK to create the project.
  5. Highlight the form called Form1.vb in the Solution Explorer window and rename it to frmAR_Provider .vb.
  6. Open the Project menu, and choose Add Reference. Make sure that the .NET tab is selected, and click Browse.
  7. Browse to the AR_Provider folder and select the NET AR_Provider.dll component. Click Open.
  8. 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
  9. 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
GrapeCity » Knowledge Base » KnowledgeBase f... » How Can I Use ActiveReports 2.0 in Visual Studio .NET?
Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.