ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Custom Exporting with TIFF
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Web Walkthroughs (Standard Edition) > Custom Web Exporting Walkthroughs > Walkthrough: Custom Exporting with TIFF

Glossary Item Box

ActiveReports provides custom components for several formats, including PDF, HTML, RTF, TIFF, Excel and plain text. Ultimate customizability is available by using any ASP.NET language.

This walkthrough illustrates how to create a simple Web application and set up custom exporting in TIFF format.

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.

You must also have access to Internet Information Services either from your computer or from the server.

When you have completed this walkthrough, you will have a TIFF image that looks similar to the following.

Adding an ActiveReport to an ASP.NET Web application

To add an ActiveReport to your project using Visual Studio 2003

  1. Create a new ASP.NET Web application. 
  2. From the Project menu, select Add New Item
  3. Select ActiveReports 3.0 File and rename the file rptCustomTiff.
  4. Click Open.

To add an ActiveReport to your project using Visual Studio 2005

  1. Create a new ASP.NET Web site. 
  2. From the Website menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptCustomTiff.
  4. Click Add.
  5. Click Yes when a message box asks whether you would like to place the class in the 'App_Code' folder.
To see the design view of your report in Visual Studio 2005, right-click the report in the Solution Explorer and select View Designer.

Connecting the report to a data source

To connect the report to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click on Build.
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  4. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products order by categoryID".
  7. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Add a GroupHeader/Footer section to rptCustomTiff by right-clicking on the design surface of the report and selecting Insert > Report Header/Footer.
  2. Make the following changes to the group header:
    • Change the Name property to ghProducts
    • Change the BackColor property to MediumPurple
    • Change the DataField property to CategoryID
  3. Add labels with the following properties to ghProducts:

    Formatting Name Text Location
    Bold lblProductID Product ID 0, 0
    Bold lblProductName Product Name 1.06, 0
    Bold lblUnitsInStock Units In Stock 3.5, 0
    Bold lblUnitsOnOrder Units On Order 4.56, 0
    Bold lblUnitPrice Unit Price 5.7, 0

  4. Make the following changes to the detail section:
    • Change the BackColor property to Lavender
    • Change the CanShrink property to True
  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the following properties of each textbox as indicated.

    DataField Text Location Output Format
    ProductID Product ID 0, 0 NA
    ProductName Product Name 1.06, 0 NA
    UnitsInStock Units In Stock 3.5, 0 NA
    UnitsOnOrder Units On Order 4.56, 0 NA
    UnitPrice Unit Price 5.7, 0 Currency

Adding the TIFF Export control to the Web Form

To add the TIFF Export control using Visual Studio 2003

  1. Click on the TiffExport control in the appropriate toolbox to select it. (See Adding ActiveReports controls for help on adding it to the toolbox.)
  2. Drag the control onto the Web Form.
  3. The control appears in the tray beneath the WebForm.

To add the TIFF Export control using Visual Studio 2005

  1. From the View menu, select Component Designer to go to the design view of the aspx file.
  2. Click on the TiffExport control in the appropriate toolbox to select it. (See Adding ActiveReports controls for help on adding it to the toolbox.)
  3. Drag the control onto the aspx design view.

Adding code to the Web Form to export to TIFF

To write the code in Visual Basic or C#

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

'Visual Basic
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim m_stream As New System.IO.MemoryStream()
    Dim rpt As New rptCustomTiff()
    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()
End Sub
    
//C#
private void Page_Load(object sender, System.EventArgs e)
{
   System.IO.MemoryStream m_stream = new System.IO.MemoryStream();
   rptCustomTiff rpt = new rptCustomTiff();
   rpt.Run();
   if (this.tiffExport1 == null) 
   { 
	this.tiffExport1 = new DataDynamics.ActiveReports.Export.Tiff.TiffExport(); 
   } 
   this.tiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff.CompressionScheme.None;
   this.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 view the results in your Web browser, run the project and click the Open button when prompted.

 

See Also

©2009. All Rights Reserved.