是否可以将 SSRS 报告与 Web 表单集成

发布于 2024-07-05 19:31:03 字数 47 浏览 5 评论 0原文

是否可以将 SSRS 报告集成到 Web 表单中……一个示例就足以让我继续前进。

Is it possible to integrate SSRS reports to the webforms..an example will be enough to keep me moving.

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

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

发布评论

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

评论(3

落在眉间の轻吻 2024-07-12 19:31:03

绝对是这样。

您正在寻找的是位于 Microsoft.Reporting.WebForms 程序集中的 ReportViewer 控件。 它将允许您在 Web 表单上放置一个控件,为人们提供一个用于设置报告参数和获取报告的界面。

或者,您可以自行设置所有参数并以您需要的任何格式输出报告。 我们在应用程序中使用它来输出 PDF。

例如 - 这就是我们如何为一份报告设置一个报表查看器对象并获取 PDF,然后将其发送回用户。 特定的代码块是一个网络处理程序。

public void ProcessRequest(HttpContext context)
{
    string report = null;
    int managerId = -1;
    int planId = -1;
    GetParametersFromSession(context.Session, out report, out managerId, out planId);
    if (report == null || managerId == -1 || planId == -1)
    {
        return;
    }

    CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;

    List<ReportParameter> parameters = new List<ReportParameter>();
    parameters.Add(new ReportParameter("Prefix", report));
    parameters.Add(new ReportParameter("ManagerId", managerId.ToString()));
    parameters.Add(new ReportParameter("ActionPlanId", planId.ToString()));
    string language = Thread.CurrentThread.CurrentCulture.Name;
    language = String.Format("{0}_{1}", language.Substring(0, 2), language.Substring(3, 2).ToLower());
    parameters.Add(new ReportParameter("Lang", language));

    ReportViewer rv = new ReportViewer();
    rv.ProcessingMode = ProcessingMode.Remote;
    rv.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
    if (ConfigurationManager.AppSettings["DbYear"] == "2007")
    {
        rv.ServerReport.ReportPath = "/ActionPlanning/Plan";
    }
    else
    {
        rv.ServerReport.ReportPath = String.Format("/ActionPlanning{0}/Plan", ConfigurationManager.AppSettings["DbYear"]);
    }
    rv.ServerReport.SetParameters(parameters);

    string mimeType = null;
    string encoding = null;
    string extension = null;
    string[] streamIds = null;
    Warning[] warnings = null;
    byte[] output = rv.ServerReport.Render("pdf", null, out mimeType, out encoding, out extension, out streamIds, out warnings);

    context.Response.ContentType = mimeType;
    context.Response.BinaryWrite(output);
}

Absolutely it is.

What you are looking for is the ReportViewer control, located in the Microsoft.Reporting.WebForms assembly. It will allow you to place a control right on your web form that will give people an interface for setting report parameters and getting the report.

Alternatively you can set all the parameters yourself and output the report in whatever format you need. We use it in our application to output PDF.

For instance - this is how we setup a reportviewer object for one of our reports and get the PDF, and then send it back to the user. The particular code block is a web handler.

public void ProcessRequest(HttpContext context)
{
    string report = null;
    int managerId = -1;
    int planId = -1;
    GetParametersFromSession(context.Session, out report, out managerId, out planId);
    if (report == null || managerId == -1 || planId == -1)
    {
        return;
    }

    CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;

    List<ReportParameter> parameters = new List<ReportParameter>();
    parameters.Add(new ReportParameter("Prefix", report));
    parameters.Add(new ReportParameter("ManagerId", managerId.ToString()));
    parameters.Add(new ReportParameter("ActionPlanId", planId.ToString()));
    string language = Thread.CurrentThread.CurrentCulture.Name;
    language = String.Format("{0}_{1}", language.Substring(0, 2), language.Substring(3, 2).ToLower());
    parameters.Add(new ReportParameter("Lang", language));

    ReportViewer rv = new ReportViewer();
    rv.ProcessingMode = ProcessingMode.Remote;
    rv.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
    if (ConfigurationManager.AppSettings["DbYear"] == "2007")
    {
        rv.ServerReport.ReportPath = "/ActionPlanning/Plan";
    }
    else
    {
        rv.ServerReport.ReportPath = String.Format("/ActionPlanning{0}/Plan", ConfigurationManager.AppSettings["DbYear"]);
    }
    rv.ServerReport.SetParameters(parameters);

    string mimeType = null;
    string encoding = null;
    string extension = null;
    string[] streamIds = null;
    Warning[] warnings = null;
    byte[] output = rv.ServerReport.Render("pdf", null, out mimeType, out encoding, out extension, out streamIds, out warnings);

    context.Response.ContentType = mimeType;
    context.Response.BinaryWrite(output);
}
烦人精 2024-07-12 19:31:03

这是一篇知识库文章,描述如何以特定文件格式将报表输出呈现到 aspx 页面。

http://support.microsoft.com/kb/875447/en-us

this is a knowledge base article which describes how to render report output to an aspx page in a particular file format.

http://support.microsoft.com/kb/875447/en-us

匿名。 2024-07-12 19:31:03

请注意,如果不使用 URL 访问方法,您将失去一些功能,例如参数选择内容。

报表服务器 URL 访问支持 HTML 查看器和报表工具栏的扩展功能。 SOAP API 不支持这种类型的呈现报告。 如果您使用 SOAP 呈现报表,则需要设计和开发自己的报表工具栏。

http://msdn.microsoft.com/en-us/library/ms155089。 ASPX

Be warned that you will lose some functionality such as the parameter selection stuff when you do not use the URL Access method.

Report server URL access supports HTML Viewer and the extended functionality of the report toolbar. The SOAP API does not support this type of rendered report. You need to design and develop your own report toolbar, if you render reports using SOAP.

http://msdn.microsoft.com/en-us/library/ms155089.aspx

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