ActiveReports for .NET 3 Online Help Request technical support
HTML, Tables and Exporting with RichText
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > RichText Walkthroughs > HTML, Tables and Exporting with RichText

Glossary Item Box

ActiveReports supports exporting with tables in the RichText control. RichText controls can be loaded with an RTF file that contains tables, or even an HTML file, and the resulting report can be exported to any of a number of formats.

This walkthrough illustrates how to create and export a report which contains the RichText control.

This walkthrough is split up into the following activities:

To complete the walkthrough, you will need an RTF file which contains a table.

Adding an ActiveReport to the 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 rptRich.
  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 below the Windows Form.

Adding controls to the report to contain data

To add controls to the report

  1. Add the following controls to the Detail section:

    Control Name Size Location
    RichTextBox RichTextBoxRTF 3, 1.5 0, 0
    RichTextBox RichTextBoxHTML 3, 1.5 3.25, 0

Creating an RTF file to be loaded into a RichText control

To write a quick RTF file

  1. Open Wordpad, and paste the following text into it.

    Customer List by Country

    Argentina

    • Rancho grande
    • Océano Atlántico Ltda.
    • Cactus Comidas para llevar

    Austria

    • Piccolo und mehr
    • Ernst Handel

    Belgium

    • Suprêmes délices
    • Maison Dewey

    Brazil

    • Familia Arquibaldo
    • Wellington Improtadora
    • Que Delícia
    • Tradição Hipermercados
    • Ricardo Adocicados
    • Hanari Carnes
    • Queen Cozinha
    • Comércio Mineiro
    • Gourmet Lanchonetes

    Month Sales
    October $4,872
    November $8,517
    December $9,623

  2. Save the file as "sample.rtf" in the bin directory (VB) or the debug directory in the bin (C#) of your project.

Loading an RTF file into a RichText control

To load an RTF file into the RichText control

To write the code in Visual Basic or C#

Creating an HTML file to be loaded into a RichText control

To write a quick HTML file

  1. Open Notepad and paste the following code into it.

    <html>
    <body>
    <center><h1>Customer List by Country</h1></center>
    <h2>Argentina</h2>
    <ul>
    <li>Rancho grande
    <li>Océano Atlántico Ltda.
    <li>Cactus Comidas para llevar
    </ul>
    <h2>Austria</h2>
    <ul>
    <li>Piccolo und mehr
    <li>Ernst Handel
    </ul>
    <h2>Belgium</h2>
    <ul>
    <li>Suprêmes délices
    <li>Maison Dewey
    </ul>
    <h2>Brazil</h2>
    <ul>
    <li>Familia Arquibaldo
    <li>Wellington Improtadora
    <li>Que Delícia
    <li>Tradição Hipermercados
    <li>Ricardo Adocicados
    <li>Hanari Carnes
    <li>Queen Cozinha
    <li>Comércio Mineiro
    <li>Gourmet Lanchonetes
    </ul>
    <table>
    <tr><th>Month</th><th>Sales</th></tr>
    <tr><td>October</td><td>$4,872</td></tr>
    <tr><td>November</td><td>$8,517</td></tr>
    <tr><td>December</td><td>$9,623</td></tr>
    </table>
    </body>
    </html>
  2. Save the file as "sample.html" in the bin directory (VB) or the debug directory in the bin (C#) of your project.

Loading the HTML file into a RichText control

To write the code in Visual Basic or C#

Viewing the report

To view the report

  1. Add the ActiveReports viewer control to the Windows Form..
  2. Set the viewer control's Dock property to Fill.
  3. Add the code needed to set the viewer document equal to the report document.

To write the code for the viewer in Visual Basic or C#

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

To write the code in Visual Basic or C#

See Also

©2009. All Rights Reserved.