RDLC报表总结

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

RDLC报表

一、RDLC介绍

在VS2005之前,SQL Server Reporting Services中已经提供了一种被称为报表定义语言(Report Definition Language, RDL)的语言;在VS2005中,Microsoft提供了针对这种报表的设计器,并提供了在WinForm和WebForm中使用这种报表的能力。RDL是Report Definition Language的缩写,C代表Client-side processing,凸显了它的客户端处理能力。

从SQL Server2005开始,微软提供了一个报表服务,即Reporting Service,利用该服务部署在服务器端的报表扩展名为rdl;而通过自主生成一些数据源,在本地展现出来的报表扩展名为rdlc,这种方式称之为Local Report。

二、如何开发

下面是LocalReport的开发步骤,对于ServerReport还没有进行研究。

1.新建一个Web工程,新建一个aspx页面。

2.将ReportViewer控件添加到新建的aspx页面中。

(视图—工具箱—数据—ReportViewer)

VS2005的数据控件中有名为ReportViewer的控件,用于展现报表。该控件即可以展现rdl 报表也可以展现rdlc报表。

3.新建报表文件

选中web工程—右键添加—新建项—选中报表(如下图)

4.创建自己的报表布局

(以柱状图为例)

工具箱—图表—拖放到报表文件主体中

选中图表—右键—图表类型—柱形图—简单柱形图

可以直接修改属性调整布局,也可以利用工具栏中的布局按钮布局(包括水平居中、垂直居中、对齐网格等)

5.创建数据集(选中web工程—右键添加—新建项—选中数据集)

在新建的数据集面板右键—添加—TableAdapter

配好数据库连接之后,下一步,有三种选择方式:使用sql语句、新建存储过程、使用现有存储过程。根据需求选择一种配好自己的数据源。

6.设计报表(绑定数据集)

打开建好的rdlc报表文件,双击添加的图表,会看到下图几个区域:

工具栏—数据—显示数据源

找到刚刚创建的数据集,将对应的字段方别拖放到数据字段区、类别字段区。序列图例会根据数据字段自动生成。

现在可以修改图表的属性来修改柱形图的配色、X和Y轴的间距、示例序列的文字、网格线的显示样式等丰富的设置来设计自己的图表。

7.打开新建的aspx页面,在ReportViewer任务窗口中,选择刚才建立的rdlc文件

如下图:选择报表中选择刚刚新建的ReportDemo.rdlc报表

8.保存,编译

如果配置的数据源为Sql语句方式,或者是不带参数的存储过程,此时就可以浏览一下aspx 页面,不用写一句代码就可以看到一个柱形图的报表。

三、动态生成报表

实际项目开发中,我们多会采用带参数的存储过程来获得想要的数据,这样就能根据条件有选择的查看数据,而不是每次都查看全部,这就涉及到传递参数,动态生成报表。可以在前台页面设置查询条件,然后获取条件后重新为报表绑定数据源。后台代码如下:

当然,也可以不配置数据集,而是在后台代码通过或者企业库等获得DataSet,然后再动态绑定到报表。示例后台代码:

四、控制报表自带的导出格式

RDLC自带丰富的导出格式,导出的Excel文件格式非常完美,任何其它报表在这方面都不能与之比拟。但是有时候我们不需要一些格式,比如不需要pdf等格式,怎么实现?

另外:ReportViewer的一些属性可以控制工具条上一些按钮的显示

ShowFindControls 是否显示查找

ShowPageNavigationControls 是否显示分页

ShowPrintButton 是否显示打印

ShowRefreshButton 是否显示刷新

ShowZoomControl 是否显示调整大小

五、ReportViewer control - Choosing between LocalReport and

ServerReport

There was a similar discussion in this group previously. You can refer the same: /Forums/en/vsreportcontrols/thread/1b06b84a-3c6e-40f1-908e-07 e332a45a04 [ReportViewer control local and remote mode differences]

Both Local Mode and Remote mode has their own advantages.. This is completely based on your requirement you can choose Local mode or remote mode of report processing.

When to Use Local Processing

Local processing mode is recommended for applications that include small to medium-sized reports and datasets. Because all data and report processing is performed on the client, you might encounter performance degradation or memory limitations if you attempt to process large or complex reports and queries.

Local processing mode is less scalable than remote processing and is intended for standalone applications that do not require a report server. Users who are familiar with server reports that run on a remote SQL Server Reporting Services report server should note the following differences: In remote processing mode, the report server both retrieves the data and processes the report, whereas in local processing mode, the ReportViewer control processes the report only, and the the host application must retrieve the data and supply it to the ReportViewer control.

Client report definitions do not include query information.

Report parameters in client report definitions (.rdlc) do not map to data source query parameters.

There is no parameter input area for a client report definition that accepts values that are subsequently used in a query

When to Use Remote Processing

Server-based reporting lets you centralize report storage and management, set policies and secure access to reports and folders, control how reports are processed and distributed, and standardize how reports are used in your business. Reporting Services can be installed in single-server, distributed, and clustered configurations. Consider using remote processing if your report has the following characteristics:

Report will be accessed by many users.

Report has a very complex query or contains a very large amount of data, resulting in system resource overload on the computer that hosts the application.

Report is already published on a report server, and you want to include it an application that you create and deploy.

相关文档
最新文档