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