gpt4 book ai didi

reporting-services - 将 SSRS 2016 报告嵌入到另一个没有 iFrame 的网页中?

转载 作者:行者123 更新时间:2023-12-04 04:29:47 24 4
gpt4 key购买 nike

Reporting-services 2016(目前仅作为技术预览版提供)带有重大升级,包括 HTML5 渲染和合规性。见:https://msdn.microsoft.com/en-us/library/ms170438.aspx

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

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

我还尝试将报告作为图像( rs:Format=IMAGE&rc:OutputFormat=PNG )获取,但生成的 PNG 在报告元素周围有一个巨大的白色框架(即使在报告生成器中将背景设置为透明),这是不可行的。

最佳答案

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

// 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 - 将 SSRS 2016 报告嵌入到另一个没有 iFrame 的网页中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35839885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com