将ReportServer报表转存为PDF

using Microsoft.Reporting.WebForms;/引用
 
ReportViewer reportview = new ReportViewer();//web界面显示RS报表控件
        reportview.ProcessingMode = ProcessingMode.Remote;//控件处理模式,Remote远程,.Local本地
        reportview.ServerReport.ReportServerUrl = new Uri("http://pcberp02/Reportserver");//报表服务器
        reportview.ServerReport.ReportPath = "/报表/发展公司/中央采购/采购报表/采购商务对账单";//报表地址,注意不加.rdl后缀

        ReportParameter[] reportParam = new ReportParameter[2];//报表传参,2代表两个参数
        reportParam[0] = new ReportParameter("FACTORY", FactoryID.ToString(), false);
        reportParam[1] = new ReportParameter("AO_NUMBER", aoinfo.AO_Number, false);
        reportview.ServerReport.SetParameters(reportParam);
        reportview.ShowParameterPrompts = false;//是否显示参数提示值
 Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string extension;
        //string deviceInfo;
        byte[] bytes = reportview.ServerReport.Render(
        "PDF", null, out mimeType, out encoding, out extension,
        out streamids, out warnings);//读取报表流
        FileStream fs = new FileStream(filePath, FileMode.Create);
        fs.Write(bytes, 0, bytes.Length);//存储,filePath为绝对路径地址
        fs.Close();
 
        reportview.ShowToolBar = false;
        reportview.ShowReportBody = false;

 

posted on 2013-06-14 09:37  cw_volcano  阅读(514)  评论(0编辑  收藏  举报