ReportViewer如何去掉或隐藏导出excel按钮?超简单的,测试在 dotnet 4.0 Microsoft.ReportViewer 10.0.0.0
不管你要去掉PDF或是WORD都行,要改字都行
Hide/Disable Export PDF EXCEL WORD Options On ReportViewer C#
- private void reportViewer1_Load(object sender, EventArgs e)
- {
- ReportViewer_PreRender(sender, e);
- }
- protected void ReportViewer_PreRender(object sender, EventArgs e)
- {
- ReportViewer rw = sender as ReportViewer;
- if (rw == null)
- {
- return;
- }
- foreach (RenderingExtension re in rw.LocalReport.ListRenderingExtensions())
- {
- if (re.Name.ToUpper() == "EXCEL") //PDF or WORD
- HideRender(re);
- }
- }
- private static void HideRender(RenderingExtension re)
- {
- Type renderType = re.GetType();
-
- FieldInfo info = re.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
- info.SetValue(re, false);
- //FieldInfo info = re.GetType().GetField("m_localizedName", BindingFlags.Instance | BindingFlags.NonPublic);
- //if (info != null) info.SetValue(re, "Excel 97-2003 Workbook");
- }
复制代码 |
|