大马资讯论坛 - 马来西亚中文资讯平台
标题:
[教学] .net 4 - ReportViewer如何去掉或隐藏导出excel按钮?
[打印本页]
作者:
资讯王
时间:
2013-8-28 20:08
标题:
[教学] .net 4 - ReportViewer如何去掉或隐藏导出excel按钮?
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");
}
复制代码
欢迎光临 大马资讯论坛 - 马来西亚中文资讯平台 (http://freeinfo.com.my/)
Powered by Discuz! X3.3