zoukankan      html  css  js  c++  java
  • Only export to PDF format from ReportViewer addin

    Hi all,

    "Only export to PDF format from ReportViewer add-in"...Is this possible? Right now the reportviewer has two options of exporting the current report-Excel and PDF...Is it possible to have PDF as the only option. I don't want my clients to export it to excel.

    Thanks in advance....

    bullpit

    ----------------------------

    As far as I know you can't remove excel export from ReportViewer.

    You can only hide export control and only allow user to print the page.

    ----------------------------

    Or you can use a button outside the reportviewer and use the local report's render function to export to pdf only.

    ----------------------------

    I got this code. but I don't want to save. I want to Export the  Report into  PDF and open directly but How?????.

       string mimeType;
            string encoding;
            string fileNameExtension;
            string[] streams;
            Microsoft.Reporting.WebForms.Warning[] warnings;

            byte[] pdfContent = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            //Creatr PDF file on disk
            string pdfPath = @"C:\temp\reportBarcode.pdf";
            System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create);
            pdfFile.Write(pdfContent, 0, pdfContent.Length);
            pdfFile.Close();

    ----------------------------

    Heres what I have.

    private void saveRptAsBas(String s_rptType)
        {        
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;
            // string deviceInfo;
            DataSet ds = GetSalesDataFull();
            // This if() block may not be required for you
            // It just the nRows parameter in the report before exporting
            if ((s_rptType == "EXCEL") || (s_rptType == "PDF"))
            {
                ReportParameter param = new ReportParameter("nRows", ds.Tables[0].Rows.Count.ToString());
                this.ReportViewer2.LocalReport.SetParameters(new ReportParameter[] { param });
            }
            
            byte[] bytes = ReportViewer2.LocalReport.Render(
            s_rptType, null, out mimeType, out encoding, out extension,
            out streamids, out warnings);
    
            /*
            FileStream stream = File.OpenWrite(@"C:\Documents and Settings\michael.shorten\Local 
            Settings\Temp\sample.pdf");
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();
            */
    
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename=Report." + extension);
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
        }

    ----------------------------

    http://forums.asp.net/p/1067131/2328201.aspx#2328201

    ----------------------------

    <script type="text/javascript" language="javascript">
       var obj=document.getElementById('ReportViewer1_ctl01_ctl05_ctl00');
       if (obj)
       { var element_length=obj.length; 
       var index=-1;    
       for(z=0;z<element_length;z++)  
       {       
        if (obj.options[z].value=='Excel')
        {index=z;}                
       }
       if(index!=-1)   
       obj.remove(index); //obj.options.remove(index);
       }   
       </script>

  • 相关阅读:
    linux下查看主板内存槽与内存信息
    centos 6 与 centos 7 服务开机启动、关闭设置的方法
    linux 配置本地光盘YUM源
    linux crontab定时任务不执行
    Linux下安装MySQL5.6
    Linux shell 自动删除n天前日志
    nginx request_time 和upstream_response_time
    linux中文件多行合并为一行的例子
    awk 处理文本:行转列,列转行
    nfs环境搭建报错clnt_create: RPC: Program not registered
  • 原文地址:https://www.cnblogs.com/emanlee/p/1563495.html
Copyright © 2011-2022 走看看