ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Exporting Output
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Basic > Walkthrough: Exporting Output

Glossary Item Box

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

This walkthrough illustrates how to export a report to PDF, HTML, RTF, Text, TIFF and Excel files.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

When you have completed this walkthrough, you will have created PDF, HTML, RTF, Text, TIFF and Excel files which can be found in the Bin/Debug (C#) or Bin (VB.NET) subfolder of your project's folder.

Adding an ActiveReport to a Visual Studio project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptExports.
  4. Click Open.

Adding the export filters to your project

To add the export filters to your project

  1. Click on the following export controls one at a time in the appropriate toolbox to select them.
    • HtmlExport
    • PdfExport
    • RtfExport
    • TextExport
    • TiffExport
    • XlsExport
  2. Drag each control onto the Windows Form.
  3. The controls will appear in the component tray underneath the Windows Form.

Connecting the report to a data source

To connect the report to a data source

  1. Return to the report and click the gray report DataSource icon in the Detail section to open the Report Datasource dialog.
  2. Select the "OLE DB" tab. 
  3. Click Build.
  4. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  5. Click the ellipsis to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to continue.
  7. In the Query field, type "Select LastName, FirstName from Employees."
  8. Click OK to return to the report design surface.

Adding controls to display the data

To add controls to the report

Using the export methods to export files to all available file formats

To write the code in Visual Basic or C#

The following example shows what the code for the method looks like.

'Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load
   Dim rpt As New rptExports()
   rpt.Run()
	 
   Me.HtmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html")
   Me.PdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf")
   Me.RtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf")
   Me.TextExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt")
   Me.TiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff")
   Me.XlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xls")
End Sub
//C#
private void Form1_Load(object sender, System.EventArgs e)
{
   rptExports rpt = new rptExports();
   rpt.Run();
	 
   this.htmlExport1.Export(rpt.Document, Application.StartupPath + "\\HTMLExpt.html");
   this.pdfExport1.Export(rpt.Document, Application.StartupPath + "\\PDFExpt.pdf");
   this.rtfExport1.Export(rpt.Document, Application.StartupPath + "\\RTFExpt.rtf");
   this.textExport1.Export(rpt.Document, Application.StartupPath + "\\TextExpt.txt");
   this.tiffExport1.Export(rpt.Document, Application.StartupPath + "\\TIFFExpt.tiff");
   this.xlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xls");
}

Build the project then navigate to the appropriate folder to see each export.

See Also

©2009. All Rights Reserved.