Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding SSRS 2016 reports into another webpage without iFrame?

Reporting-services 2016 (currently only available as a technical preview) comes with big-upgrades including HTML5 rendering and compliance. See: https://msdn.microsoft.com/en-us/library/ms170438.aspx

My desire is to embed SSRS 2016 reports into another webpage using native mode (no Sharepoint or aspx, just pure HTML5). The traditional fashion to do this is to use an iFrame. This is an half-way okay method as it's possible to remove the toolbar, hide parameters etc but still you end up losing a lot of control over the document. This is a cross-site implementation from a different domain so I can't manipulate the contained iFrame document as I please.

Does there exist an official way to embed the report element 'natively'? I could envision a URL parameter option like rs:Format=REPORTDIV which serves me a html element.

I also tried fetching the report as an image (rs:Format=IMAGE&rc:OutputFormat=PNG) but the resulting PNG has a huge white frame (even when setting background to transparent in Report Builder) around the report element which is a no-go.

like image 504
Wollan Avatar asked Mar 07 '16 09:03

Wollan


People also ask

How do I display an SSRS report on one page?

If you're trying to display report data in one page, it is simple to do in SSRS. All you have to do is select an entire table and then go to the property pane. Update KeepTogather = True. Show activity on this post.

How do I display HTML content in SSRS report?

we can display html content in ssrs by selecting 'HTML-Interpret html tags as styles' present in placeholder properties.


1 Answers

This should work. It should work outside of the environment as well as it embeds the images from memory instead of fetching them from the database

// Create service instance
            ReportExecutionServiceSoapClient rsExec = new ReportExecutionServiceSoapClient(binding, endpoint);
            rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            rsExec.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

            ReportingServices.Extension[] extentions = null;
            ReportingServices.TrustedUserHeader trustedUserHeader = new ReportingServices.TrustedUserHeader();
            rsExec.ListRenderingExtensions(trustedUserHeader, out extentions);
            string reportPath = "/Untitled";
            ExecutionInfo execInfo = new ExecutionInfo();
            ExecutionHeader execHeader = new ExecutionHeader();
            ReportingServices.ServerInfoHeader serverInfo = new ReportingServices.ServerInfoHeader();
            string historyID = null;

            rsExec.LoadReport(trustedUserHeader, reportPath, historyID, out serverInfo, out execInfo);

            //Get execution ID
            execHeader.ExecutionID = execInfo.ExecutionID;
            string deviceInfo = null;
            string extension;
            string encoding;
            string mimeType;
            ReportingServices.Warning[] warnings = new ReportingServices.Warning[1];
            warnings[0] = new ReportingServices.Warning();
            string[] streamIDs = null;

            string format = "HTML5";
            Byte[] result;
            rsExec.Render(execHeader, trustedUserHeader, format, deviceInfo, out result, out extension, out mimeType, out encoding, out warnings, out streamIDs);

            var report = Encoding.UTF8.GetString(result);
            int streamIdCount = streamIDs.Length;
            Byte[][] imageArray = new Byte[streamIdCount][];
            String[] base64Images = new String[streamIdCount];
            for (int i = 0; i <= streamIdCount - 1; i++)
            {
                Byte[] result2;
                string streamId = streamIDs[i];
                rsExec.RenderStream(execHeader, trustedUserHeader, format, streamId, deviceInfo, out result2, out encoding, out mimeType);
                imageArray[i] = result2;
                base64Images[i] = Convert.ToBase64String(result2);
                string replace = string.Format("https://<reportserver>/ReportServer?%2FUntitled&rs%3ASessionID={0}&rs%3AFormat={1}&rs%3AImageID={2}", execInfo.ExecutionID, format, streamId);
                string src = string.Format("data:{0};charset=utf-8;base64, {1}", mimeType, base64Images[i]);
                report = report.Replace(replace, src);
            }
like image 134
user7549557 Avatar answered Oct 30 '22 09:10

user7549557