Out of the box SSRS reports cannot have data exposed in the page header. Is there a way to get this data to show?
开箱即用的SSRS报告不能在页眉中公开数据。有没有办法让这些数据显示出来?
7 个解决方案
#1
6
One of the things I want in my reports is to have nice headers for my reports. I like to have a logo and the user's report parameters along with other data to show to give more information for the business needs the report needs to clarify. One of the things that Microsoft SQL Server 2005 Reporting Services cannot do natively is show data from a Dataset in the header. This post will explain how to work around this and how easy it is.
我在报告中想要的一件事就是为我的报告提供漂亮的标题。我希望有一个徽标和用户的报告参数以及其他数据,以便为报告需要澄清的业务需求提供更多信息。 Microsoft SQL Server 2005 Reporting Services无法本机执行的操作之一是显示标头中数据集的数据。这篇文章将解释如何解决这个问题以及它是多么容易。
Create the Report Server Project in the Business Intelligence Projects section and call it AdventureWorksLTReports. I use the AdventureWorksLT sample database from CodePlex.
在Business Intelligence Projects部分中创建Report Server项目,并将其命名为AdventureWorksLTReports。我使用CodePlex的AdventureWorksLT示例数据库。
alt text http://www.cloudsocket.com/images/image-thumb.png
alt text http://www.cloudsocket.com/images/image-thumb.png
Next show the Page Header by right clicking in the Report area with the designer.
接下来,通过在设计器中右键单击“报告”区域来显示页眉。
alt text http://www.cloudsocket.com/images/image-thumb1.png
alt text http://www.cloudsocket.com/images/image-thumb1.png
The Page Header will appear. If you want to show the Page Footer this can be accessed from the same menu as the Page Header.
页面标题将出现。如果要显示页脚,可以从与页眉相同的菜单访问该页脚。
alt text http://www.cloudsocket.com/images/image-thumb2.png
alt text http://www.cloudsocket.com/images/image-thumb2.png
I created a stored procedure that returns data for the Sales Order to be presented in the Page Header. I will show the following information about the Sales Order in the Page Header:
我创建了一个存储过程,该过程返回要在页眉中显示的销售订单的数据。我将在页眉中显示有关销售订单的以下信息:
- Order Date
- Sales Order Number
- Company
- Sales Person
- Total Due
销售订单号
I create a TextBox for each of my data fields in the Page Header along with a TextBox for the corresponding label. Do not change the Expression in the TextBoxes that you want the Sales Order data in.
我为页眉中的每个数据字段创建一个TextBox以及相应标签的TextBox。不要更改要在其中输入销售订单数据的文本框中的表达式。
alt text http://www.cloudsocket.com/images/image-thumb3.png
alt text http://www.cloudsocket.com/images/image-thumb3.png
In the Report Body, place a TextBox for each data field needed in the Page Header. In the Visibility for each TextBox, select True for Hidden. This will be the placeholder for the data needed in the Page Header.
在报表正文中,为页眉中所需的每个数据字段放置一个TextBox。在每个TextBox的Visibility中,为隐藏选择True。这将是页眉中所需数据的占位符。
alt text http://www.cloudsocket.com/images/image-thumb4.png
alt text http://www.cloudsocket.com/images/image-thumb4.png
Your report should look similar to the screenshot shown below.
您的报告应类似于下面显示的屏幕截图。
alt text http://www.cloudsocket.com/images/image-thumb5.png
alt text http://www.cloudsocket.com/images/image-thumb5.png
The last step and most important is to reference the Hidden TextBox in the TextBoxes located in the Page Header. We use the the following Expression to reference the needed TextBoxes:
最后一步,最重要的是引用位于页眉中的TextBox中的隐藏文本框。我们使用以下Expression来引用所需的TextBoxes:
=ReportItems!.Value
Your report should now look similar to the following:
您的报告现在应该类似于以下内容:
alt text http://www.cloudsocket.com/images/image-thumb6.png
alt text http://www.cloudsocket.com/images/image-thumb6.png
Your Report preview should now have the Sales Order Header data in the Report Header.
您的报表预览现在应该在报表头中包含销售订单表头数据。
alt text http://www.cloudsocket.com/images/image-thumb7.png
alt text http://www.cloudsocket.com/images/image-thumb7.png
#2
4
You have to do it through Parameters. Add a parameter for each piece of data you would like to display, then set the parameter to Hidden. Then set the default value to "From Query" and set the Dataset and Value field to the appropriate values.
你必须通过参数来做到这一点。为要显示的每个数据添加一个参数,然后将参数设置为Hidden。然后将默认值设置为“From Query”并将“数据集和值”字段设置为适当的值。
#3
1
I think the best option is creating a internal parameter, with the default value the field of the dataset you want to show.
我认为最好的选择是创建一个内部参数,默认值是您要显示的数据集的字段。
#4
0
Here are two possible workarounds:
以下是两种可能的解决方法:
-
You can place the databound field within the body of the report as a hidden textbox, and then in the header place another textbox with it's value pointed at the the one hidden within the body.
您可以将数据绑定字段作为隐藏文本框放在报表正文中,然后在标题中放置另一个文本框,其值指向隐藏在正文中的文本框。
-
Try using report parameters to store the data, and use those parameters to access the data in the header.
尝试使用报告参数来存储数据,并使用这些参数来访问标头中的数据。
#5
0
This technique wouldn't work if your report spans over multiple pages, use queried parameters instead, and set the textbox value to =Parameters!Name.Value as per this article.
如果您的报告跨越多个页面,使用查询的参数,并将文本框值设置为= Parameters!Name.Value,则此技术将不起作用。
#6
0
I'm with Orion Adrian here. Report parameters are the way to go.
我和猎户座阿德里安在这里。报告参数是要走的路。
#7
0
I wanted to show a field, common to all returned rows, in the header, and for this scenario I went for the linked table solution (placing a table containing the field in the body and link a textbox in the header to this table).
我想在标题中显示所有返回行共有的字段,对于这种情况,我选择了链接表解决方案(将包含字段的表放在正文中,并将标题中的文本框链接到此表)。
I did that because if you are using the parameter solution and no data is returned to the field in question, the text "Parameter is missing a value" is shown instead of just a blank table. I reckoned this text would confuse users (as the parameter isn't even visible).
我这样做是因为如果您使用参数解决方案并且没有数据返回到相关字段,则会显示“参数缺少值”文本而不是空白表。我估计这个文本会混淆用户(因为参数甚至不可见)。
#1
6
One of the things I want in my reports is to have nice headers for my reports. I like to have a logo and the user's report parameters along with other data to show to give more information for the business needs the report needs to clarify. One of the things that Microsoft SQL Server 2005 Reporting Services cannot do natively is show data from a Dataset in the header. This post will explain how to work around this and how easy it is.
我在报告中想要的一件事就是为我的报告提供漂亮的标题。我希望有一个徽标和用户的报告参数以及其他数据,以便为报告需要澄清的业务需求提供更多信息。 Microsoft SQL Server 2005 Reporting Services无法本机执行的操作之一是显示标头中数据集的数据。这篇文章将解释如何解决这个问题以及它是多么容易。
Create the Report Server Project in the Business Intelligence Projects section and call it AdventureWorksLTReports. I use the AdventureWorksLT sample database from CodePlex.
在Business Intelligence Projects部分中创建Report Server项目,并将其命名为AdventureWorksLTReports。我使用CodePlex的AdventureWorksLT示例数据库。
alt text http://www.cloudsocket.com/images/image-thumb.png
alt text http://www.cloudsocket.com/images/image-thumb.png
Next show the Page Header by right clicking in the Report area with the designer.
接下来,通过在设计器中右键单击“报告”区域来显示页眉。
alt text http://www.cloudsocket.com/images/image-thumb1.png
alt text http://www.cloudsocket.com/images/image-thumb1.png
The Page Header will appear. If you want to show the Page Footer this can be accessed from the same menu as the Page Header.
页面标题将出现。如果要显示页脚,可以从与页眉相同的菜单访问该页脚。
alt text http://www.cloudsocket.com/images/image-thumb2.png
alt text http://www.cloudsocket.com/images/image-thumb2.png
I created a stored procedure that returns data for the Sales Order to be presented in the Page Header. I will show the following information about the Sales Order in the Page Header:
我创建了一个存储过程,该过程返回要在页眉中显示的销售订单的数据。我将在页眉中显示有关销售订单的以下信息:
- Order Date
- Sales Order Number
- Company
- Sales Person
- Total Due
销售订单号
I create a TextBox for each of my data fields in the Page Header along with a TextBox for the corresponding label. Do not change the Expression in the TextBoxes that you want the Sales Order data in.
我为页眉中的每个数据字段创建一个TextBox以及相应标签的TextBox。不要更改要在其中输入销售订单数据的文本框中的表达式。
alt text http://www.cloudsocket.com/images/image-thumb3.png
alt text http://www.cloudsocket.com/images/image-thumb3.png
In the Report Body, place a TextBox for each data field needed in the Page Header. In the Visibility for each TextBox, select True for Hidden. This will be the placeholder for the data needed in the Page Header.
在报表正文中,为页眉中所需的每个数据字段放置一个TextBox。在每个TextBox的Visibility中,为隐藏选择True。这将是页眉中所需数据的占位符。
alt text http://www.cloudsocket.com/images/image-thumb4.png
alt text http://www.cloudsocket.com/images/image-thumb4.png
Your report should look similar to the screenshot shown below.
您的报告应类似于下面显示的屏幕截图。
alt text http://www.cloudsocket.com/images/image-thumb5.png
alt text http://www.cloudsocket.com/images/image-thumb5.png
The last step and most important is to reference the Hidden TextBox in the TextBoxes located in the Page Header. We use the the following Expression to reference the needed TextBoxes:
最后一步,最重要的是引用位于页眉中的TextBox中的隐藏文本框。我们使用以下Expression来引用所需的TextBoxes:
=ReportItems!.Value
Your report should now look similar to the following:
您的报告现在应该类似于以下内容:
alt text http://www.cloudsocket.com/images/image-thumb6.png
alt text http://www.cloudsocket.com/images/image-thumb6.png
Your Report preview should now have the Sales Order Header data in the Report Header.
您的报表预览现在应该在报表头中包含销售订单表头数据。
alt text http://www.cloudsocket.com/images/image-thumb7.png
alt text http://www.cloudsocket.com/images/image-thumb7.png
#2
4
You have to do it through Parameters. Add a parameter for each piece of data you would like to display, then set the parameter to Hidden. Then set the default value to "From Query" and set the Dataset and Value field to the appropriate values.
你必须通过参数来做到这一点。为要显示的每个数据添加一个参数,然后将参数设置为Hidden。然后将默认值设置为“From Query”并将“数据集和值”字段设置为适当的值。
#3
1
I think the best option is creating a internal parameter, with the default value the field of the dataset you want to show.
我认为最好的选择是创建一个内部参数,默认值是您要显示的数据集的字段。
#4
0
Here are two possible workarounds:
以下是两种可能的解决方法:
-
You can place the databound field within the body of the report as a hidden textbox, and then in the header place another textbox with it's value pointed at the the one hidden within the body.
您可以将数据绑定字段作为隐藏文本框放在报表正文中,然后在标题中放置另一个文本框,其值指向隐藏在正文中的文本框。
-
Try using report parameters to store the data, and use those parameters to access the data in the header.
尝试使用报告参数来存储数据,并使用这些参数来访问标头中的数据。
#5
0
This technique wouldn't work if your report spans over multiple pages, use queried parameters instead, and set the textbox value to =Parameters!Name.Value as per this article.
如果您的报告跨越多个页面,使用查询的参数,并将文本框值设置为= Parameters!Name.Value,则此技术将不起作用。
#6
0
I'm with Orion Adrian here. Report parameters are the way to go.
我和猎户座阿德里安在这里。报告参数是要走的路。
#7
0
I wanted to show a field, common to all returned rows, in the header, and for this scenario I went for the linked table solution (placing a table containing the field in the body and link a textbox in the header to this table).
我想在标题中显示所有返回行共有的字段,对于这种情况,我选择了链接表解决方案(将包含字段的表放在正文中,并将标题中的文本框链接到此表)。
I did that because if you are using the parameter solution and no data is returned to the field in question, the text "Parameter is missing a value" is shown instead of just a blank table. I reckoned this text would confuse users (as the parameter isn't even visible).
我这样做是因为如果您使用参数解决方案并且没有数据返回到相关字段,则会显示“参数缺少值”文本而不是空白表。我估计这个文本会混淆用户(因为参数甚至不可见)。