Stimulsoft Reporting Cross tab and Export to PDF

cnirmal

New member
Joined
Dec 9, 2008
Messages
1
Programming Experience
3-5
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 Downloads - Reporting Tool for .Net Framework, Runtime Royalty Free Report Designer, Web Reports for Asp.Net .
The following steps are required in order to create a cross tab and export it to pdf, word, excel and other formats
<w:sdt sdtdocpart="t" docparttype="Table of Contents" docpartunique="t" id="181166474">
<!--[if !supportLists]-->1.<!--[endif]--><!--[if supportFields]>*TOC \o "1-3" \h \z \u <![endif]-->Add report to your web page. <!--[if supportFields]> PAGEREF _Toc216452323 \h <![endif]--><o></o>
<!--[if !supportLists]-->2.<!--[endif]-->Add a new connection to the report. <!--[if supportFields]> PAGEREF _Toc216452324 \h <![endif]--><o></o>
<!--[if !supportLists]-->3.<!--[endif]-->Add a Data Source to the report. <!--[if supportFields]> PAGEREF _Toc216452325 \h <![endif]--><o></o>
<!--[if !supportLists]-->4.<!--[endif]-->Add a Cross-Tab to the report. <!--[if supportFields]> PAGEREF _Toc216452326 \h <![endif]--><o></o>
<!--[if !supportLists]-->5.<!--[endif]-->Load the Report from file. <!--[if supportFields]> PAGEREF _Toc216452327 \h <![endif]--><o></o>
<!--[if !supportLists]-->6.<!--[endif]-->Export the report to pdf. <!--[if supportFields]> PAGEREF _Toc216452328 \h <![endif]--><o></o>
<!--[if supportFields]><![endif]--><o></o>
</w:sdt> <o></o>
Add report to your web page

<!--[if !supportLists]-->·<!--[endif]-->Drag and Drop StiWebReport from the toolbox to your webpage
<!--[if !supportLists]-->·<!--[endif]-->Click on the arrow on the top right corner of StiWebReport1 to show StiWebReport Tasks
<!--[if !supportLists]-->·<!--[endif]-->Click on Design Report to open the report Desinger
<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1036" type="#_x0000_t75" style='width:388.5pt; height:141.75pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:title="" croptop="7700f" cropbottom="42353f" cropright="39014f"/> </v:shape><![endif]--><!--[if !vml]-->
image001.jpg
<!--[endif]-->
Add a new connection to the report

<!--[if !supportLists]-->·<!--[endif]-->Find the Dictionary on the right side of the report designer
<!--[if !supportLists]-->·<!--[endif]-->Click on the New Item Icon and select New Connection
<!--[if !supportLists]-->·<!--[endif]-->Select Sql Connection and click OK
<!--[if !supportLists]-->·<!--[endif]-->Type the connection string for the AdventureWorks database
<!--[if !supportLists]-->·<!--[endif]-->Click test to confirm that the connection string is correct.
<!--[if gte vml 1]><v:shape id="Picture_x0020_4" o:spid="_x0000_i1035" type="#_x0000_t75" style='width:222.75pt; height:153.75pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png" o:title="" croptop="7946f" cropbottom="40796f" cropleft="50330f"/> </v:shape><![endif]--><!--[if !vml]-->
image002.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="_x0000_i1034" type="#_x0000_t75" style='width:355.5pt;height:221.25pt; visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png" o:title="" croptop="19497f" cropbottom="21873f" cropleft="20633f" cropright="20685f"/> </v:shape><![endif]--><!--[if !vml]-->
image003.jpg
<!--[endif]-->
Add a Data Source to the report

<!--[if !supportLists]-->·<!--[endif]-->Click on the New Item icon the Dictionary pane and select New Data Source
<!--[if !supportLists]-->·<!--[endif]-->Select Data from Sql Connection and Click Ok
<!--[if !supportLists]-->·<!--[endif]-->Type the name of the query in the Name field as Sales
<!--[if !supportLists]-->·<!--[endif]-->Type the SQL query in the Query Text Field
<!--[if !supportLists]-->·<!--[endif]-->Click on Retrieve Columns to confirm that you have all the required columns
<!--[if !supportLists]-->·<!--[endif]-->Click Ok to see the Sales Datasource in the Dictionary Pane
<!--[if !supportLists]-->·<!--[endif]-->The following query has been used in the report
[FONT=&quot]SELECT[/FONT][FONT=&quot] [SalesOrderID]<o></o>[/FONT]
[FONT=&quot] ,[RevisionNumber]<o></o>[/FONT]
[FONT=&quot] ,[OrderDate]<o></o>[/FONT]
[FONT=&quot] ,[DueDate]<o></o>[/FONT]
[FONT=&quot] ,[ShipDate]<o></o>[/FONT]
[FONT=&quot] ,[Status]<o></o>[/FONT]
[FONT=&quot] ,[OnlineOrderFlag]<o></o>[/FONT]
[FONT=&quot] ,[SalesOrderNumber]<o></o>[/FONT]
[FONT=&quot] ,[PurchaseOrderNumber]<o></o>[/FONT]
[FONT=&quot] ,[AccountNumber]<o></o>[/FONT]
[FONT=&quot] ,[CustomerID]<o></o>[/FONT]
[FONT=&quot] ,[ContactID]<o></o>[/FONT]
[FONT=&quot] ,[SalesPersonID]<o></o>[/FONT]
[FONT=&quot] ,st.Name<o></o>[/FONT]
[FONT=&quot] ,[BillToAddressID]<o></o>[/FONT]
[FONT=&quot] ,[ShipToAddressID]<o></o>[/FONT]
[FONT=&quot] ,[ShipMethodID]<o></o>[/FONT]
[FONT=&quot] ,[CreditCardID]<o></o>[/FONT]
[FONT=&quot] ,[CreditCardApprovalCode]<o></o>[/FONT]
[FONT=&quot] ,[CurrencyRateID]<o></o>[/FONT]
[FONT=&quot] ,[SubTotal]<o></o>[/FONT]
[FONT=&quot] ,[TaxAmt]<o></o>[/FONT]
[FONT=&quot] ,[Freight]<o></o>[/FONT]
[FONT=&quot] ,[TotalDue]<o></o>[/FONT]
[FONT=&quot] ,[Comment]<o></o>[/FONT]
[FONT=&quot] FROM [AdventureWorks].[Sales].[SalesOrderHeader] soh<o></o>[/FONT]
[FONT=&quot]Inner[/FONT][FONT=&quot] join [AdventureWorks].[Sales].[SalesTerritory] st on soh.TerritoryID = st.TerritoryID<o></o>[/FONT]
<!--[if gte vml 1]><v:shape id="Picture_x0020_10" o:spid="_x0000_i1033" type="#_x0000_t75" style='width:225pt; height:140.25pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image007.png" o:title="" croptop="8110f" cropbottom="42107f" cropleft="50176f"/> </v:shape><![endif]--><!--[if !vml]-->
image004.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="Picture_x0020_13" o:spid="_x0000_i1032" type="#_x0000_t75" style='width:378pt; height:376.5pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image009.png" o:title="" croptop="11059f" cropbottom="13353f" cropleft="19865f" cropright="19866f"/> </v:shape><![endif]--><!--[if !vml]-->
image005.jpg
<!--[endif]-->
Add a Cross-Tab to the report

<!--[if !supportLists]-->·<!--[endif]-->Click on Cross Bands icon on the right toolbar and select Cross-Tab
<!--[if !supportLists]-->·<!--[endif]-->Draw the cross tab onto the report
<!--[if !supportLists]-->·<!--[endif]-->The Cross-Tab Designer window will appear
<!--[if !supportLists]-->·<!--[endif]-->Select Sales in the Datasource dropdown
<!--[if !supportLists]-->·<!--[endif]-->Add OrderDate in the Columns list and change the display value property and value property to [FONT=&quot]{Format("{0:yyyy}", Sales.OrderDate)}[/FONT] in order to show only the order year.
<!--[if !supportLists]-->·<!--[endif]-->Add Name to the Rows list and TotalDue in the Summary Field
<!--[if !supportLists]-->·<!--[endif]-->Click OK to save the changes.
<!--[if !supportLists]-->·<!--[endif]-->Press F5 to preview the report.
<!--[if !supportLists]-->·<!--[endif]-->This report now shows the total amounts due by sales territory and year, it also gives a total of each row and column.
<!--[if !supportLists]-->·<!--[endif]-->Save the report as Sales.mrt and close the report designer.
<!--[if gte vml 1]><v:shape id="Picture_x0020_7" o:spid="_x0000_i1031" type="#_x0000_t75" style='width:168pt; height:3in;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image011.png" o:title="" croptop=".125" cropbottom="33751f" cropright="54067f"/> </v:shape><![endif]--><!--[if !vml]-->
image006.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" style='width:781.5pt;height:382.5pt; visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image013.png" o:title="" croptop="10732f" cropbottom="13025f" cropleft="10598f" cropright="1587f"/> </v:shape><![endif]--><!--[if !vml]-->
image007.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="Picture_x0020_1" o:spid="_x0000_i1029" type="#_x0000_t75" style='width:484.5pt; height:294.75pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image015.png" o:title="" croptop="15483f" cropbottom="17859f" cropleft="16230f" cropright="16180f"/> </v:shape><![endif]--><!--[if !vml]-->
image008.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="Picture_x0020_16" o:spid="_x0000_i1028" type="#_x0000_t75" style='width:612.75pt; height:472.5pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image017.png" o:title="" cropbottom="13926f" cropright="23757f"/> </v:shape><![endif]--><!--[if !vml]-->
image009.jpg
<!--[endif]-->
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.
[FONT=&quot]protected[/FONT][FONT=&quot] void Page_Load(object sender, EventArgs [/FONT]
[FONT=&quot] {<o></o>[/FONT]
[FONT=&quot] if (StiWebViewer1.IsImageRequest) return;<o></o>[/FONT]
[FONT=&quot]<o></o>[/FONT]
[FONT=&quot] if (!Page.IsPostBack)<o></o>[/FONT]
[FONT=&quot] {<o></o>[/FONT]
[FONT=&quot] Stimulsoft.Report.StiReport oRep = StiWebReport1.GetReport();<o></o>[/FONT]
[FONT=&quot] StiWebViewer1.Report = oRep;<o></o>[/FONT]
[FONT=&quot] }<o></o>[/FONT]
[FONT=&quot] }[/FONT]
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.
<!--[if gte vml 1]><v:shape id="Picture_x0020_19" o:spid="_x0000_i1027" type="#_x0000_t75" style='width:514.5pt; height:282.75pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image019.png" o:title="" croptop="7864f" cropbottom="26788f" cropleft="7936f" cropright="22477f"/> </v:shape><![endif]--><!--[if !vml]-->
image010.jpg
<!--[endif]-->
<!--[if gte vml 1]><v:shape id="Picture_x0020_28" o:spid="_x0000_i1026" type="#_x0000_t75" style='width:675.75pt; height:552pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image021.png" o:title=""/> </v:shape><![endif]--><!--[if !vml]-->
image011.jpg
<!--[endif]-->
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.
<!--[if gte vml 1]><v:shape id="Picture_x0020_34" o:spid="_x0000_i1025" type="#_x0000_t75" style='width:675.75pt; height:552pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:\Users\Chirag\AppData\Local\Temp\msohtmlclip1\01\clip_image023.png" o:title=""/> </v:shape><![endif]--><!--[if !vml]-->
image012.jpg
<!--[endif]-->
<o>
</o>
 
Back
Top