有没有办法将子报表放在SSRS的标题中?

发布于 2024-08-08 10:07:03 字数 90 浏览 3 评论 0原文

我想使用子报告,因为它在许多报告的标题中使用。但是,子报告不会进入标题,字段值也不会进入。不过,参数会很好。

关于如何绕过这个问题有什么建议或参考吗?

I would like to use a sub report, since it gets used on many reports, in the header. However, sub reports won't go into the header and neither will field values. Although, parameters will go just fine.

Any suggestions or references for how to bypass this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

忆梦 2024-08-15 10:07:03

我以另一种方式处理这个问题。

创建了一个仅包含页眉和页脚的报告。

然后,对于我们需要的每个报告,我们只需创建一个子报告。

我知道它远非完美。但这对我们的报告有用。

另一种选择是创建一个程序集,将数据泵入标头中的字段中。如果标题中没有太图形化的内容,则效果很好......

I approcahed this the other way.

Created a report which just contained a header and a footer.

Then for every report we need we just created a sub report.

I know it isn't anywhere near perfect. But it worked for our reports.

Another option is to create an assembly which pumps data into a field in the header. Works fine if there's nothing too graphical in the header...

伤感在游骋 2024-08-15 10:07:03

我也遇到过完全相同的问题。几个小时后,我找到了解决方案(没有子报告)。

SSRS 2012 中存在“矩形”。我从来没有真正研究过它,因为我认为它只是用于图形用途。事实上,您可以将多个元素分组在其中。您可以将整个矩形发布为报表部分。您可以在其他报表中使用此报表部分,甚至可以在页眉或页脚中使用。

I've been confronted with the exact same problem. After several hours, I found a solution (without a subreport).

In SSRS 2012 exists the "Rectangle". I never really looked into it because I thought it's just for graphical use. In fact you can group multiple elements in it. The whole rectangle you can publish as Reportpart. This reportpart you can use in other reports, even in the header or footer.

风启觞 2024-08-15 10:07:03

在页眉或页脚的母版页级别使用 Globals!PageName 内置字段,然后在每个子报表中定义 PageName 值。这将允许页眉或页脚根据 PageName 变量中定义的字符串值进行更改。

例如:将页脚文本框设置为:[&PageName]=Globals!PageName

在母版页调用的每个子报表中,定义 PageName 值设置为:

<PageName>This is the Dynamic Page Footer String.  You can include subreport names, or any dynamic subreport text here </PageName>

我在代码视图中的子报表中、在该部分正下方的 tablix 定义中设置 PageName 值:

<DataSetName>YourDataSetName</DataSetName> 

有关可以使用的全局变量的更多详细信息,请参阅:
https://msdn.microsoft.com/en-us/library/dd255216.aspx

Use the Globals!PageName Built-in-field at the Master Page level in the header or footer, then define the PageName value in each subreport. This will allow the header or footer to change with the string value defined in the PageName variable.

For example: set a footer textbox to: [&PageName] or =Globals!PageName

In each subreport called by the Master Page, define the PageName value to:

<PageName>This is the Dynamic Page Footer String.  You can include subreport names, or any dynamic subreport text here </PageName>

I set the PageName value in the subreports, in code view, in the tablix definition directly below the section:

<DataSetName>YourDataSetName</DataSetName> 

For more details on Global variables that you can use look at:
https://msdn.microsoft.com/en-us/library/dd255216.aspx

灼痛 2024-08-15 10:07:03

一个建议可能对有限的情况有帮助:您可以使用数据集中的默认值填充参数,并在标头中使用该参数。当然,这一次只能为您提供一个字段/值,但如果您只需要从数据库中将一两个项目放入标头中,这可能是一个不错的解决方法。

One suggestion that may help in a limited subset of cases: you can fill a parameter with a default value from a dataset, and use that parameter in the header. Of course, this only gets you one field/value at a time, but if you only need one or two items from the database into your header this may be a decent workaround.

自我难过 2024-08-15 10:07:03

SSRS 不允许将子报告放入标头中。我遇到过这个问题,我想我有一个解决方案。添加子报表作为附加数据集,并将响应放入文本框中。它对我有用...?

SSRS will not allow subreports into the Header. I have had this issue, and I think I have a solution. Add the subreport as an additional dataset, and put the response into a text box. It works for me...?

清秋悲枫 2024-08-15 10:07:03

从这个答案中得到了想法:
https://stackoverflow.com/a/57991114/11829240

无法真正将其发布在那里,因为该主题是关于rdlc,它只是客户端。
但我想说它适合这里。

创建一个图像,将其大小设置为按比例,使用以下网址:

http://*reportserverUser*:*reportserverPassword*@*ssrsHost*/ReportServer?%2f*reportName*&rs:Command=Render&rs:Format=IMAGE&rc:OutputFormat=BMP&rc:dpix=1000&rc:dpiy=1000

&rs:Format=IMAGE 给我一个图像。

&rc:OutputFormat=BMP 作为 BMP,因为报表无法处理 TIFF。

&rc:dpix=1000&rc:dpiy=1000 给我一个更高的分辨率,所以它看起来不会难看

编辑:似乎可以在 VisualStudio 中本地工作,但不能在 ReportServer 上工作。可能必须创建一个自定义 DLL 来进行身份验证。

EDIT2:

[System.Security.SecuritySafeCritical]
[WebPermission(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
public static string GetReport(string reportname)
{

    // request file permission for config-file
    FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Read, @"c:\ssrs\ssrsutils_auth.txt");
    f.Assert();

    // BASE-URL\tusername\tpassword
    var config = File.ReadAllText(@"c:\ssrs\ssrsutils_auth.txt");

    // Get BASE-URL and insert reportname into {0} placeholder
    var str = string.Format(config.Split('\t')[0], reportname);
    var requestUri = new Uri(str);

    // Set Credentials according to configuration
    NetworkCredential nc = new NetworkCredential(config.Split('\t')[1], config.Split('\t')[2]);

    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

    request.Credentials = nc;

    // Give me an Image object
    var img = Image.FromStream(request.GetResponse().GetResponseStream());

    // and return as Base64
    return GetBase64(img);
}

private static string GetBase64(Image image)
{
    using (MemoryStream m = new MemoryStream())
    {
        image.Save(m, ImageFormat.Png);
        byte[] imageBytes = m.ToArray();
        return Convert.ToBase64String(imageBytes);
    }
}

然后将图像源设置为数据库,使用以下表达式:

=*Project*.*Class*.GetReport("*ReportName*")

Mime Type to image/bmp ,您就可以开始

示例配置c:\ssrs\ssrsutils_auth.txt (将 [TAB] 替换为实际的 \t - ASCII 09):

http://*ssrsHost*/ReportServer?%2f{0}&rs:Command=Render&rs:Format=IMAGE&rc:OutputFormat=BMP&rc:dpix=1000&rc:dpiy=1000[TAB]username[TAB]password

顺便说一句,请注意,SSRS 处理 CAS。
https://stackoverflow.com/a/61816621/11829240

Got the idea from this answer:
https://stackoverflow.com/a/57991114/11829240

can't really post it there, since the topic is about rdlc, which is only client-side.
But I would say it fits here.

Create an image, set its size to fit proportionally, with the following url:

http://*reportserverUser*:*reportserverPassword*@*ssrsHost*/ReportServer?%2f*reportName*&rs:Command=Render&rs:Format=IMAGE&rc:OutputFormat=BMP&rc:dpix=1000&rc:dpiy=1000

&rs:Format=IMAGE give me an Image.

&rc:OutputFormat=BMP as a BMP, since Reports can't handle TIFF's.

&rc:dpix=1000&rc:dpiy=1000 give me a higher resolution, so it wont look ugly

EDIT: Seems to work locally in VisualStudio but not on the ReportServer. Might have to create a custom DLL for the authentication.

EDIT2:

[System.Security.SecuritySafeCritical]
[WebPermission(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
public static string GetReport(string reportname)
{

    // request file permission for config-file
    FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Read, @"c:\ssrs\ssrsutils_auth.txt");
    f.Assert();

    // BASE-URL\tusername\tpassword
    var config = File.ReadAllText(@"c:\ssrs\ssrsutils_auth.txt");

    // Get BASE-URL and insert reportname into {0} placeholder
    var str = string.Format(config.Split('\t')[0], reportname);
    var requestUri = new Uri(str);

    // Set Credentials according to configuration
    NetworkCredential nc = new NetworkCredential(config.Split('\t')[1], config.Split('\t')[2]);

    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

    request.Credentials = nc;

    // Give me an Image object
    var img = Image.FromStream(request.GetResponse().GetResponseStream());

    // and return as Base64
    return GetBase64(img);
}

private static string GetBase64(Image image)
{
    using (MemoryStream m = new MemoryStream())
    {
        image.Save(m, ImageFormat.Png);
        byte[] imageBytes = m.ToArray();
        return Convert.ToBase64String(imageBytes);
    }
}

Then you set the image-source to database, use the following expression:

=*Project*.*Class*.GetReport("*ReportName*")

Mime Type to image/bmp and you are good to go

Example-Config c:\ssrs\ssrsutils_auth.txt (replace [TAB] with actual \t - ASCII 09):

http://*ssrsHost*/ReportServer?%2f{0}&rs:Command=Render&rs:Format=IMAGE&rc:OutputFormat=BMP&rc:dpix=1000&rc:dpiy=1000[TAB]username[TAB]password

By the way, be aware of the way, SSRS handles CAS.
https://stackoverflow.com/a/61816621/11829240

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文