微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用telerik报表控件生成报表


Collapse image

Create 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 @R_880_4045@ion.

  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

如图:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐