【问题标题】:SSRS to Excel missing images and header when access via url通过 url 访问时,SSRS 到 Excel 缺少图像和标题
【发布时间】:2013-05-01 18:20:29
【问题描述】:

我正在从 Intranet 站点加载 SSRS 报告。当我转到 SSRS 报告管理器并将文档导出到 Excel 时,它会与所有项目一起导出。

但是,当我通过网页做同样的事情时,我会丢失一些标题和图像。

这是我的 C# 代码

Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer();
                    rview.ServerReport.ReportServerUrl = new Uri(uri);
                    rview.ServerReport.ReportPath = "/T200/MiscAsset";

                    //For the ReportServerCredentials public class CustomReportCredentials must be added to the code
                    Microsoft.Reporting.WebForms.IReportServerCredentials irsc = new CustomReportCredentials(user, pass, domain);
                    rview.ServerReport.ReportServerCredentials = irsc;

                    if (_mode == null)
                    {
                        _mode = "PDF";
                    }

                    string deviceInfo, mimeType, encoding, extention;
                    string[] streamaids;
                    Microsoft.Reporting.WebForms.Warning[] warnings;
                    deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>";
                    byte[] bytes = rview.ServerReport.Render(_mode, deviceInfo, out mimeType, out encoding, out extention, out streamaids, out warnings);
                    Response.Clear();

                    if (_mode == "PDF")
                    {
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("Content-disposition", "filename=MiscAsset.pdf");
                    }
                    else if (_mode == "excel")
                    {
                        Response.ContentType = "application/vnd.ms-excel";
                        Response.AddHeader("Content-disposition", "filename=MiscAsset.xls");
                    }
                    Response.OutputStream.Write(bytes, 0, bytes.Length);
                    Response.OutputStream.Flush();
                    Response.OutputStream.Close();
                    Response.Flush();
                    Response.Close();

【问题讨论】:

  • 到目前为止,您尝试过什么来解决它?遇到了什么问题,调试过程中得到了什么信息?

标签: .net excel reporting-services header export


【解决方案1】:

图片是嵌入在报告中还是外部?如果它们是外部图像,您需要确保在网页中查看时用户也具有查看外部图像的必要权限。

至于标题,您的代码设置 SimplePageHeaders = True。这意味着当报表导出到 Excel 时,报表标题将呈现为 Excel 页标题,而不是工作表的一部分。尝试将此设置为 False。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-21
    • 2018-01-13
    • 1970-01-01
    • 2018-03-09
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 2013-03-19
    相关资源
    最近更新 更多