0

我正在从 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();
4

1 回答 1

0

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

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

于 2013-05-01T21:26:40.743 回答