Glossary Item Box

Tasks: Visual Studio.NET 2005 Web Changes

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Custom Exporting with TIFF

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 (NWind.mdb). You must also have access to Internet Information Services either from your computer or from the server. You must also run the "Configure Web Sample" option from the Data Dynamics ActiveReports for .NET 2.0 program menu from your Windows Start button.

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

Important: If you are using Visual Studio.NET 2005, please see the Visual Studio.NET 2005 Web Changes topic.

To add an ActiveReport to your project

  1. Open a new ASP.NET Web application in Visual Studio.
  2. Click on Project > Add New Item.
  3. Select ActiveReports file and rename the file rptTIFF.
  4. Click Open.

Connecting the report to a data source

To connect the report to a data source

  1. Click on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>
  4. Click on the ellipsis to browse for the access path to NWind.mdb. 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 rptTIFF.
  2. Make the following changes to the group header:
    • Change the name to ghProducts
    • Change the DataField property to CategoryID
  3. Add the following controls to the GroupHeader section:

    Control Name Text/Caption Location
    Label lblProductID Product ID 0, 0
    Label lblProductName Product Name 1.0625, 0
    Label lblUnitsInStock Units In Stock 2.6875, 0
    Label lblUnitsOnOrder Units On Order 3.75, 0
    Label lblUnitPrice Unit Price 4.8125, 0

  4. Add the following controls to the Detail section:

    Control DataField Name Text/Caption Location Output Format
    TextBox ProductID txtProductID Product ID 0, 0 (Empty string)
    TextBox ProductName txtProductName Product Name 1.0625, 0 (Empty string)
    TextBox UnitsInStock txtUnitsInStock Units In Stock 2.6875, 0 (Empty string)
     
    TextBox UnitsOnOrder txtUnitsOnOrder Units On Order 3.75, 0 (Empty string)
    TextBox UnitPrice txtUnitPrice Unit Price 4.8125, 0 Currency

Adding the TIFF Export control to the Web Form

To add the TIFF Export control

Note: If you are using Visual Studio 2005, please see Visual Studio.NET 2005 Web Changes.
  1. Click on the TIFF Export control in the appropriate toolbox to select it.
  2. Drag the control onto the Web Form.
  3. The control will appear in the tray underneath the Web Form.

Adding code to the Web Form to export to TIFF

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 Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ MyBase.Load
Dim m_stream As New System.IO.MemoryStream()
Dim rpt As New rptTIFF()
rpt.Run()
Me.TiffExport1.CompressionScheme = DataDynamics.ActiveReports.Export.Tiff _ .CompressionScheme.Lzw
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();
rptTIFF rpt = new rptTIFF();
rpt.Run();
this.tiffExport1.CompressionScheme = CompressionScheme.Lzw;
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();
}

Tasks: Visual Studio.NET 2005 Web Changes

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.