11

Reporting-services 2016(目前仅作为技术预览版提供)进行了重大升级,包括 HTML5 呈现和合规性。请参阅:https ://msdn.microsoft.com/en-us/library/ms170438.aspx

我的愿望是使用本机模式(没有 Sharepoint 或 aspx,只有纯 HTML5)将 SSRS 2016 报告嵌入到另一个网页中。执行此操作的传统方式是使用 iFrame。这是一个半途而废的方法,因为它可以删除工具栏、隐藏参数等,但你最终还是会失去对文档的很多控制权。这是来自不同域的跨站点实现,因此我无法随意操作包含的 iFrame 文档。

是否存在“本地”嵌入报告元素的官方方式? 我可以设想一个 URL 参数选项,例如rs:Format=REPORTDIV它为我提供一个 html 元素。

rs:Format=IMAGE&rc:OutputFormat=PNG我还尝试将报告获取为图像 (

4

1 回答 1

3

这应该有效。它应该在环境之外工作,并且它应该从内存中嵌入图像而不是从数据库中获取它们

// 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);
            }
于 2017-02-11T09:20:45.173 回答