Reporting Services参数小谈

HTML Viewer Commands

The following table describes the URL access parameters that are prefixed with rc: and are used to target the HTML Viewer.

Use this parameter To

Toolbar

Show or hide the toolbar. If the value of this parameter is false, all remaining options are ignored. If you omit this parameter, the toolbar is automatically displayed for rendering formats that support it. The default of this parameter is true.

Parameters

Show or hide the parameters area of the toolbar. If you set this parameter to true, the parameters area of the toolbar is displayed. If you set this parameter to false, the parameters area is not displayed and cannot be displayed by the user. If you set this parameter to a value of Collapsed, the parameters area will not be displayed, but can be toggled by the end user. The default value of this parameter is true.

Zoom

Set the report zoom value as an integer percentage or a string constant. Standard string values include Page Width and Whole Page. This parameter is ignored by versions of Microsoft Internet Explorer earlier than Internet Explorer 5.0 and all non-Microsoft browsers. The default value of this parameter is 100.

Section

Set which page in the report to display. Any value that is greater than the number of pages in the report displays the last page. Any value that is less than 0 displays page 1 of the report. The default value of this parameter is 1.

StartFind

Specify the first section to search. The default value of this parameter is the first page of the report.

EndFind

Set the number of the last page to use in the search. For example, a value of 5 indicates that the last page to be searched is page 5 of the report. The default value is the number of the current page. Use this parameter in conjunction with the StartFind parameter.

FallbackPage

Set the number of the page to display if a search or a document map selection fails. The default value is the number of the current page.

GetImage

Get a particular icon for the HTML Viewer user interface.

Icon

Get the icon of a particular rendering extension.

Stylesheet

Specify a style sheet to be applied to the HTML Viewer.

You can pass additional parameters on a URL to direct the output for HTML rendering. For more information, see HTML Device Information Settings.

The following table describes the URL access parameters that are prefixed with rs: and are used to target the report server.

Use this parameter To

Command

Specify the last section to search. The default value of this parameter is the last page of the report.

Format

Specify the format in which to render a report. Common values include HTML3.2, HTML4.0, HTMLOWC, MHTML, IMAGE, EXCEL, CSV, PDF, XML, and NULL. For more information, see Specifying a Rendering Format in a URL.

ParameterLanguage

Provide a language for parameters passed in a URL that is independent of the browser language. The default value is the browser language. The value can be a culture value, such as en-us or de-de.

Snapshot

Render a report based on a report history snapshot. For more information, see Rendering Report History Snapshots Using URL Access.

The following example hides the HTML Viewer toolbar by setting the rc:Toolbar parameter value to false:

http://servername/reportserver?/Sales/YearlySalesSummary&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false

The following example passes a hard-coded parameter and hides the input field for user-supplied parameters:

http://servername/reportserver?/Sales/YearlySalesSummary&rs:Command=Render&rs:Format=HTML4.0&rc:Parameters=false&Year=2002

The following example uses the rc:Zoom parameter to set the zoom property of the report to Page Width:

http://servername/reportserver?/Sales/YearlySalesSummary&rs:Command=Render&rs:Format=HTML4.0&rc:Zoom=Page Width

The following example toggles section 13 of the report:

http://servername/reportserver?/Sales/YearlySalesSummary&rs:Command=Render&rs:ShowHideToggle=13
通过直接传递参数给.aspx页面(使用ReportViewer控件呈现报表),在.aspx页面中接受参数从而呈现所需报表。主要解决方法如下: 

1.用vs.net打开ReportViewer这个项目,项目文件夹在你安装的SQL Reporting Services的相关文件夹中(见图1)。

2.打开ReportViewer.cs文件,写入以下方法(见图2),然后重新编译这个项目。

3.新建一个带参数的报表文件rdl,具体不详述,请参考我以前的文章。

4.新建一个.aspx文件,引用编译好ReportViewer.dll,拖入这个控件到.aspx页面(见图3),

可以在ReportViewer的属性栏中直接设置报表路径和报表服务器路径及相关属性,也可以在.aspx.cs的page_load中用code的方式设置(见图4)。

5.为了测试传递参数,再建一个htm页面加入一个链接,连接中加入所要传递的参数(见图5)。

6.在.aspx.cs代码中接受传递来的参数,同时要把接收到参数传递给报表,这就用到了图2中的方法了(见图6)。

7.运行后就可以得到你所传参数的报表了(见图7),上面没有查询参数框是因为在ReportViewer属性的Parameters设为false了,这样看起来界面更好一点。

总结一下:最主要的地方还是在第2步,其实我们可以添加其他类似的方法来达到自己所要的结果。如果要传递2个或3个值怎么办,其实方法也是一样的,只要在报表文件中设置2个或3个参数就可以了。另外补充一下关于导出打印的问题,其实可以在.cs代码中直接设置导出的格式,比如 this.ReportViewer1.Format=“pdf“;这样页面就直接会用acrobat打开的。

 

 

 

 

注意:直接在URL + "&city_no=350100" 也可以实现参数传递功能

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值