By using this site you agree to the use of cookies for analytics and personalized content.
I agree Learn More
Artikel
Diese technischen Artikel beschreiben die Themen, die mit den Besonderheiten verschiedener Komponenten Stimulsoft Reports verbunden sind.

Share this post

Submit to FacebookSubmit to FacebookSubmit to TwitterSubmit to TwitterSubmit to GoogleSubmit to GoogleSubmit to LinkedInSubmit to LinkedInSubmit to VKSubmit to VK
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 the website: http://www.stimulsoft.com/en/downloads

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
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


1. 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 Designer.

Add report to your web page

2. 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 a new connection to the report
Add a new connection to the report

3. 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

Add a Data Source to the report
Add a Data Source to the report

4. 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 a Cross-Tab to the report
Add a Cross-Tab to the report
Add a Cross-Tab to the report
Add a Cross-Tab to the report

5. 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.

Load the Report from file
Load the Report from file

6. Export the report to PDF

  • Click on the save and select Adobe Pdf;
  • Users can export the report to a wide variety of formats shown below;
  • No coding or external library is required to export.

Export the report to PDF
TwitterTwitterFacebookFacebookRSSRSSLinked inLinked inYoutubeYoutubeStimulsoft BlogStimulsoft BlogViberViberWhatsAppWhatsAppSkypeSkypeTelegramTelegram