使用telerik报表控件生成报表


Collapse imageCreate the Class Library for the Reports

To create even simple reports you start by creating a class library to contain your report and a web, windows or Silverlight application to display the report.

 Caution

It is possible to put the report definition and viewer in the same application but this route is not recommended.  See this topic on best practices for more information.

  1. Select File | New | Project from the Visual Studio File menu.  Select the Class Library project, give it a name and location.  Click the OK button to close the dialog.

    Creating the Class Library

  2. Right-click the project context menu and select Add | New Item | Telerik Report. Enter a name for the report class and click the Add button to close the dialog. In this example we name the report class file "ProductList.cs".

  3. The Telerik Report Wizard will appear automatically to help you select data and design your report quickly. Once you have the basic report layout you can go back to edit the report, add data columns and tweak the format. Click the Next button.

  4. On the Report Choice Page of the Report Wizard, select New Report and click the Next button.

  5. On the Choose Data Source page of the Report Wizard, select Add New Data Source.

  6. The DataSource Wizard is started. Select the SqlDataSource component icon and click the OK button.

  7. On the Choose Your Data Connection page select a connection for the AdventureWorks database from the drop down list. If you do not have it in the dropdown list, click New Connection and create a connection to it. When done click the Next button.

  8. The Save the Connection String step appears, where you can save the connection string in the application configuration file if you want with the name you want. Click Next.

  9. The Configure Data Source Command step will display next.
    • Click the Query Builder button.
    • In the Add Table dialog select "Product", "ProductInventory", "ProductPhoto" and "ProductProductPhoto" from the list of tables. Note: You can hold down the control key and click each of the tables to select them all at one time.
    • Click the Add button to close the dialog.

    • On the Query Builder select the fields shown in the figure below. In the Product table select "Name", "ProductNumber" and "ReorderPoint".  In ProductPhoto select the "ThumbNailPhoto" column. In the ProductInventory table select the "Quantity" column.
    • Click the OK button to close the dialog.

    • The Configure Data Source Command step would show the generated statement. Clicking the Next button would lead you to the Preview Data Source Results step, where you can preview the data. Click finish to return to the Choose Data Source page of the Report Wizard. On the next page choose Standard Report Type and click the Next button.

  10. The Design Data Layout page of the Report Wizard allows you to assign database fields to sections of the report. The Report Wizard automatically places and formats the database fields in the appropriate report sections.
    • Select from the Available Fields list on the left side of the page.
    • Select "Name", "ProductNumber", "ReorderPoint" and "Quantity".
    • After selecting each field, click the Detail button to add those columns to the detail listing of the report.
    • Click the Next button.

  11. On the Choose Report Layout page of the Report Wizard unselect the Adjust report items to fit available space checkbox. Click the Next button.

  12. On the Choose Report Style page of the Report Wizard select "Civic" from the Style Sheets list on the left side of the page. Notice the style changes in the Preview portion on the right side of the page.

  13. On the Completing the Wizard page of the Report Wizard you can review the settings for the report and click the Finish button

    The initial report layout appears in the design view in Visual Studio. 

     Note

    Notice that the wizard has automatically provided:

    • Data bound fields in the detail section of the report.
    • Styled page and column titles.
    • A page footer with standard date and page number output.

  14. Rebuild the project.
  15. Click the Preview tab of the designer to view your report.







如果要使用函数或者report Paremeter的话

可以右击report空白处设置一个parameter,然后在在design窗口中选择expression项,双击函数或者parameters

如图:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值