Is it possible to integrate SSRS reports with web forms?

Is it possible to integrate SSRS reports into web forms? For example, this will be enough so that I can move.

+3
source share
3 answers

Absolutely that.

What you are looking for is a ReportViewer control located in the Microsoft.Reporting.WebForms assembly. This will allow you to place the control directly in your web form, which will give people an interface for setting report parameters and receiving a report.

As an alternative, you can set all the parameters yourself and display the report in any format. We use it in our application to output PDF.

, reportviewer 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);
}
+7

, , , URL.

URL- HTML Viewer . SOAP API . , SOAP.

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

0

Source: https://habr.com/ru/post/1697177/


All Articles