Bean Software Logo
ASP.NET Database Search Control
 Home
    Shop
    Advertise
    Write For Us
    Affiliate
    Newsletter
    Contact

Stimulsoft Reporting Cross tab and Export to PDF

Stimulsoft reporting provides a set of powerful reporting tools Microsoft Visual Studio .net 2005 and 2008; these tools are available for windows forms as well as web forms. They provide many useful features such as an easy to use report designer and native support for exporting to pdf, word, excel and various other formats. Crystal report and Microsoft reports are great for day to day reporting, but if you need to create reports with cross-tabs and drill down, ajax, support for bar codes and connecting to more than one report source at the same time, then stimulsoft reporting is a very good solution. They also have a feature where end users can create their own reports for adhoc reporting. All these features make stimulsoft reports a good choice for business intelligence reporting.

 

In this tutorial I will show to create a simple cross tab report, show it on a web page and allow users to export the report to word, excel and pdf without writing a single line of code.

The data for this sample report will come from the AdventureWork sample database provided by Microsoft.

The demo version of Stimulsoft reporting tools can be downloaded from their website http://www.stimulsoft.com/ .

The following steps are required in order to create a cross tab and export it to pdf, word, excel and other formats

1.       Add report to your web page. 1

2.       Add a new connection to the report.

3.       Add a Data Source to the report.

4.       Add a Cross-Tab to the report.

5.       Load the Report from file.

6.       Export the report to pdf.

Add report to your web page

»         Drag and Drop StiWebReport from the toolbox to your webpage

»         Click on the arrow on the top right corner of StiWebReport1 to show StiWebReport Tasks

»         Click on Design Report to open the report Desinger

Report Designer
Image 1: Report designer

 

Add a new connection to the report

»         Find the Dictionary on the right side of the report designer

»         Click on the New Item Icon and select New Connection

»         Select Sql Connection and click OK

»         Type the connection string for the AdventureWorks database

»         Click test to confirm that the connection string is correct.

Add new connection to the report
Image 2: Adding new connection to the report

 

Set connection string of the report
Image 3: Set connection string of the report

 

Add a Data Source to the report

»         Click on the New Item icon the Dictionary pane and select New Data Source

»         Select Data from Sql Connection and Click Ok

»         Type the name of the query in the Name field as Sales

»         Type the SQL query in the Query Text Field

»         Click on Retrieve Columns to confirm that you have all the required columns

»         Click Ok to see the Sales Datasource in the Dictionary Pane

»         The following query has been used in the report

SELECT [SalesOrderID]

,[RevisionNumber]

,[OrderDate]

,[DueDate]

,[ShipDate]

,[Status]

[OnlineOrderFlag]

,[SalesOrderNumber]

,[PurchaseOrderNumber]

,[AccountNumber]

,[CustomerID]

,[ContactID]

,[SalesPersonID]

,st.Name

,[BillToAddressID]

,[ShipToAddressID]

,[ShipMethodID]

,[CreditCardID]

,[CreditCardApprovalCode]

,[CurrencyRateID]

,[SubTotal]

,[TaxAmt]

,[Freight]

,[TotalDue]

,[Comment]

   FROM [AdventureWorks].[Sales].[SalesOrderHeader] soh

Inner join [AdventureWorks].[Sales].[SalesTerritory] st on soh.TerritoryID = st.TerritoryID

Set new data source to the report
Image 4: Set new data source to the report

 

Set columns to the report
Image 5: Set table columns used in report

 

Add a Cross-Tab to the report

»         Click on Cross Bands icon on the right toolbar and select Cross-Tab

»         Draw the cross tab onto the report

»         The Cross-Tab Designer window will appear

»         Select Sales in the Datasource dropdown

»         Add OrderDate in the Columns list and change the display value property and value property to {Format("{0:yyyy}", Sales.OrderDate)} in order to show only the order year.

»         Add Name to the Rows list and TotalDue in the Summary Field

»         Click OK to save the changes.

»         Press F5 to preview the report.

»         This report now shows the total amounts due by sales territory and year, it also gives a total of each row and column.

»         Save the report as Sales.mrt and close the report designer.

Add cross tab report
Image 6: Add cross tab report

 

Creating of report
Image 7: Creating a report in design view (click to enlarge image)

 

Report text editor
Image 8: Report text editor

 

Report viewer
Image 9: Report viewer

 

Load the Report from file

Click on the right arrow on the StiWebReport1 object on the aspx page and select Open report from file

Browse to the location where you saved the report as an .mrt file.

Show report in the report viewer

Drag and Drop a StiwebViewer object to the page where Stiwebreport1 object already exists.

Add the following code to the page load event of the page.

protected void Page_Load(object sender, EventArgs e)
{
   
if (StiWebViewer1.IsImageRequest) return;
      
if (!Page.IsPostBack)
      
{
         
Stimulsoft.Report.StiReport oRep = StiWebReport1.GetReport();
         
StiWebViewer1.Report = oRep;
       
}
}

The first line is required as part of the stireports framework.

The second if statement is used to load the report only once when the page load occurs and the 2 lines in the if statement set the report source of the report viewer.

Press F5 to view the report as a web report.

View report as web report
Image 10: View report as web report

 

Web report at run time
Image 11: Web report at run time

 

Export the report to pdf

»         Click on the save and select Abobe Pdf.

»         Users can export the report to a wide variety of formats shown below

»         No coding or external library is required to export.

Saving report to PDF format
Image 12: Report could be saved in different formats, including PDF

 

This tutorial is written by Chirag Nirmal.


Tutorial toolbar:  Tell A Friend  |  Add to favorites  |  Feedback  |   


comments powered by Disqus

Related articles:

1. System Registry in .NET
2. Creating Invoice in Stimulsoft Reports