ActiveReports provides components that allow you to export your reports into several popular formats. The following walkthroughs demonstrate how to set up report custom exporting to PDF, Excel, TIFF, RTF, and plain text formats. You can similarly export to HTML, or you can create a custom HTML outputter.
![]() |
Note: You can instead add a reference to ActiveReports.HtmlExport in the Solution Explorer if you prefer. |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1 rpt.Run() If Me.PdfExport1 Is Nothing Then Me.PdfExport1 = New DataDynamics.ActiveReports.Export.Pdf.PdfExport End If PdfExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=MyExport.pdf") Response.BinaryWrite(m_stream.ToArray()) Response.End() |
To write the code in C#
C# code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.pdfExport1 == null) { this.pdfExport1 = new DataDynamics.ActiveReports.Export.Pdf.PdfExport(); } pdfExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition","attachment;filename=MyExport.pdf"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); |
![]() |
Note: To use the one-touch printing option, add the following to the code above.
|
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.XlsExport1 Is Nothing Then Me.XlsExport1 = New DataDynamics.ActiveReports.Export.Xls.XlsExport End If XlsExport1.MinColumnWidth = 0.5 XlsExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition", "inline; filename=MyExport.xls") Response.BinaryWrite(m_stream.ToArray()) Response.End() |
To write the code in C#
C# code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.xlsExport1 == null) { this.xlsExport1 = new DataDynamics.ActiveReports.Export.Xls.XlsExport(); } xlsExport1.MinColumnWidth = 0.5f; xlsExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition","inline; filename=MyExport.xls"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.TiffExport1 Is Nothing Then Me.TiffExport1 = New DataDynamics.ActiveReports.Export.Tiff.TiffExport End If Me.TiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff.CompressionScheme.None Me.TiffExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "image/tiff" Response.AddHeader("content-disposition", "inline; filename=MyExport.tiff") Response.BinaryWrite(m_stream.ToArray()) Response.End() |
To write the code in C#
C# code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.tiffExport1 == null) { this.tiffExport1 = new DataDynamics.ActiveReports.Export.Tiff.TiffExport(); } tiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff.CompressionScheme.None; tiffExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "image/tiff"; Response.AddHeader("content-disposition","inline; filename=MyExport.tiff"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.RtfExport1 Is Nothing Then Me.RtfExport1 = New DataDynamics.ActiveReports.Export.Rtf.RtfExport End If RtfExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "application/msword" Response.AddHeader("content-disposition", "inline; filename=MyExport.rtf") Response.BinaryWrite(m_stream.ToArray()) Response.End() |
To write the code in C#
C# code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.rtfExport1 == null) { this.rtfExport1 = new DataDynamics.ActiveReports.Export.Rtf.RtfExport(); } rtfExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "application/msword"; Response.AddHeader("content-disposition","inline; filename=MyExport.rtf"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
Dim m_stream As New System.IO.MemoryStream() Dim rpt As New NewActiveReport1() rpt.Run() If Me.TextExport1 Is Nothing Then Me.TextExport1 = New DataDynamics.ActiveReports.Export.Text.TextExport End If TextExport1.Export(rpt.Document, m_stream) m_stream.Position = 0 Response.ContentType = "text/plain" Response.AddHeader("content-disposition", "attachment; filename=MyExport.txt") Response.BinaryWrite(m_stream.ToArray()) Response.End() |
To write the code in C#
C# code. Paste INSIDE the Page Load event. |
Copy Code |
---|---|
System.IO.MemoryStream m_stream = new System.IO.MemoryStream(); NewActiveReport1 rpt = new NewActiveReport1(); rpt.Run(); if (this.textExport1 == null) { this.textExport1 = new DataDynamics.ActiveReports.Export.Text.TextExport(); } textExport1.Export(rpt.Document, m_stream); m_stream.Position = 0; Response.ContentType = "text/plain"; Response.AddHeader("content-disposition", "attachment; filename=MyExport.txt"); Response.BinaryWrite(m_stream.ToArray()); Response.End(); |
To view the results in your Web browser, run the project.