• crm SSRS 报表 导出格式控制


    如果是使用的网页嵌入ReportView的方式的,可以在aspx上加入js来控制导出格式:

    <script src="js/jquery-1.9.0.js"></script> 
    <script type="text/javascript"> 
    // 使用jquery 1.9 主要是为了兼容ie 6/7/8
    $(document).ready(function(e) {
    
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='XML']").remove();
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='CSV']").remove();
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='MHTML']").remove();
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='EXCELOPENXML']").remove();
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='IMAGE']").remove();
    $("#ReportViewer1_ctl01_ctl05_ctl00 option[value='WORDOPENXML']").remove();
    
    }); 
    </script>

    如果是asp.net 可以使用,我没有试这个

    public static class ReportViewerExtensions
     {
     public static void SetExportFormatVisibility(this ReportViewer viewer, ReportViewerExportFormat format, bool isVisible)
     {
     
     string formatName = format.ToString();
     
     const System.Reflection.BindingFlags Flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance;
     System.Reflection.FieldInfo m_previewService = viewer.LocalReport.GetType().GetField("m_previewService", Flags);
     
     System.Reflection.MethodInfo ListRenderingExtensions = m_previewService.FieldType.GetMethod("ListRenderingExtensions", Flags);
     object previewServiceInstance = m_previewService.GetValue(viewer.LocalReport);
     
     IList extensions = (IList)ListRenderingExtensions.Invoke(previewServiceInstance, null);
     System.Reflection.PropertyInfo name = extensions[0].GetType().GetProperty("Name", Flags);
     
     //object extension = null;
     foreach (var ext in extensions)
     {
     
     if ((string.Compare(name.GetValue(ext, null).ToString(), formatName, true) == 0))
     {
     System.Reflection.FieldInfo m_isVisible = ext.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     
     System.Reflection.FieldInfo m_isExposedExternally = ext.GetType().GetField("m_isExposedExternally", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     m_isVisible.SetValue(ext, isVisible);
     m_isExposedExternally.SetValue(ext, isVisible);
     
     break;
     }
     
     }
     }
     
     }
     
     public enum ReportViewerExportFormat
     {
     Excel,
     PDF
     }
    Simple to use..
    
    
    ReportViewer1.SetExportFormatVisibility(ReportViewerExportFormat.PDF, false);
  • 相关阅读:
    C语言文本文件实现局部修改
    TTMS框架设计思路及实例介绍
    浅谈函数与操作符的重载
    Java:继承与多态
    Java:类与对象(二)
    Java : 类与对象(一)
    C语言 数的阶乘、高次幂、大数加法及大数乘法
    C语言下的位运算
    enum:枚举类型介绍与简单使用
    C语言实现字符界面下的学生管理成绩系统
  • 原文地址:https://www.cnblogs.com/BinBinGo/p/5502035.html
Copyright © 2020-2023  润新知