Glossary Item Box
ActiveReports supports exporting with tables in the RichText control. RichText controls can be loaded with an RTF file which 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.
To add an ActiveReport to your project
To add the export filters to your project
To add controls to the report
| Control | DataField | Name | Text/Caption | Misc Details | Location |
|---|---|---|---|---|---|
| RichText | (Empty string) | rtfRTF | (Empty string) | (Empty string) | 0, 0 |
| RichText | (Empty string) | rtfHTML | (Empty string) | (Empty string) | 0, 0 |
To load an RTF file into the RichText control
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
[Visual Basic]
Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
Detail.Format
rtfRTF.LoadFile(Application.StartupPath & "\sample.rtf")
End Sub[C#]
private void Detail_Format(object sender, System.EventArgs eArgs)
{
rtfRTF.LoadFile(System.Windows.Forms.Application.StartupPath + "\\sample.rtf");
}To write a quick HTML file
<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>
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
'Visual Basic
Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
Detail.Format
rtfRTF.LoadFile(Application.StartupPath & "\sample.rtf")
Dim stream As New System.IO.FileStream(Application.StartupPath & "\sample.html", _
IO.FileMode.Open)
rtfHTML.Load(stream, RichTextType.Html)
stream.Close()
End Sub//C#
private void Detail_Format(object sender, System.EventArgs eArgs)
{
rtfRTF.LoadFile(System.Windows.Forms.Application.StartupPath + "\\sample.rtf");
System.IO.FileStream stream = new System.IO.FileStream(System.Windows.Forms
.Application.StartupPath + "\\sample.html",System.IO.FileMode.Open);
rtfHTML.Load(stream, RichTextType.Html);
stream.Close();
}To view the report
To write the code for the viewer in Visual Basic
To write the code for the viewer in C#
The following example shows what the code for the method looks like.
' Visual Basic Private Sub Viewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ Viewer1. Load Dim rpt As New rptRich() Viewer1.Document = rpt.Document rpt.Run() End Sub
//C#
private void viewer1_Load(object sender, System.EventArgs e)
{
rptMain rpt = new rptMain();
this.viewer1.Document = rpt.Document;
rpt.Run();
}To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
'Visual Basic
Private Sub Viewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles arv.Load
Dim rpt As New rptDD
rpt.Run()
arv.Document = rpt.Document
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 viewer1_Load(object sender, System.EventArgs e)
{
rptDD rpt = new rptDD();
rpt.Run();
arv.Document = rpt.Document;
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");
}
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.