ReportViewer tempReportViewer = new ReportViewer();
tempReportViewer.ProcessingMode = ProcessingMode.Remote;
tempReportViewer.ServerReport.ReportServerUrl = new Uri("http://hczb-pc/ReportServer");//报表服务器
tempReportViewer.ServerReport.ReportPath = "/HHD/HHD Satisfaction Survey Template";//报表地址,注意不加.rdl后缀
try
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
//string deviceInfo;
byte[] bytes = tempReportViewer.ServerReport.Render(
"PDF", null, out mimeType, out encoding, out extension,
out streamids, out warnings);//读取报表流
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + "Report.pdf");
Response.BinaryWrite(bytes);
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
}