在没有 iFrame 的情况下将 SSRS 2016 报告嵌入到另一个网页中?
Embedding SSRS 2016 reports into another webpage without iFrame?
Reporting-services 2016(目前仅作为技术预览版提供)进行了重大升级,包括 HTML5 呈现和合规性。参见:https://msdn.microsoft.com/en-us/library/ms170438.aspx
我的愿望是使用本机模式(没有 Sharepoint 或 aspx,只是纯 HTML5)将 SSRS 2016 报告嵌入到另一个网页中。
执行此操作的传统方式是使用 iFrame。
这是一种半途而废的方法,因为它可以删除工具栏、隐藏参数等,但最终您仍然会失去对文档的很多控制。这是来自不同域的跨站点实现,因此我无法随心所欲地操作包含的 iFrame 文档。
是否存在嵌入报告元素的官方方法'natively'?
我可以设想一个像 rs:Format=REPORTDIV
这样的 URL 参数选项,它为我提供 html 元素。
我也尝试将报告作为图像获取 (rs:Format=IMAGE&rc:OutputFormat=PNG
),但是生成的 PNG 在报告元素周围有一个巨大的白框(即使在 Report Builder 中将背景设置为透明时),这是一个 no-去吧。
这应该有效。它应该在环境之外工作,并且它从内存中嵌入图像而不是从数据库中获取图像
// 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);
}
Reporting-services 2016(目前仅作为技术预览版提供)进行了重大升级,包括 HTML5 呈现和合规性。参见:https://msdn.microsoft.com/en-us/library/ms170438.aspx
我的愿望是使用本机模式(没有 Sharepoint 或 aspx,只是纯 HTML5)将 SSRS 2016 报告嵌入到另一个网页中。 执行此操作的传统方式是使用 iFrame。 这是一种半途而废的方法,因为它可以删除工具栏、隐藏参数等,但最终您仍然会失去对文档的很多控制。这是来自不同域的跨站点实现,因此我无法随心所欲地操作包含的 iFrame 文档。
是否存在嵌入报告元素的官方方法'natively'?
我可以设想一个像 rs:Format=REPORTDIV
这样的 URL 参数选项,它为我提供 html 元素。
我也尝试将报告作为图像获取 (rs:Format=IMAGE&rc:OutputFormat=PNG
),但是生成的 PNG 在报告元素周围有一个巨大的白框(即使在 Report Builder 中将背景设置为透明时),这是一个 no-去吧。
这应该有效。它应该在环境之外工作,并且它从内存中嵌入图像而不是从数据库中获取图像
// 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);
}