通过 ReportViewer 生成报告时禁用 Excel 导出选项
当我在 winforms 应用程序中通过 ReportViewer 生成报告时,如何禁用 Excel 导出选项?
添加: 特别是,我想隐藏引用 Excel 输出/导出任务的工具栏按钮,而不是隐藏处理 pdf 导出选项的按钮。
How can I disable the Excel export option when I generate a report, via the ReportViewer, in my winforms application?
ADDITION:
In particular, I want to hide the toolbar button that refers to Excel output/export task, and not .the one that handles to the pdf export option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这将完成海报要求的内容(使用一点 LINQ 从集合中选择某些类型的对象):
This will accomplish what the poster asked (uses a little LINQ for selecting objects of certain types from collections):
虽然从表面上看这似乎很容易,但导出选项很难掌握。您可以通过简单地执行以下操作来获取报表查看器的工具条:
...您可以迭代 .Items 集合以对按钮执行您喜欢的操作,但是导出按钮的 DropDownItems 集合始终显示为空。
因此,简单的解决方案是摆脱默认的导出按钮,并添加您自己的导出按钮,仅包含您需要的功能。所以在你的表单构造函数中:
那么你需要做的就是处理实际的导出:
While on the face of it this seems easy, the export options are difficult to get hold of. You can get the toolstrip of the reportviewer by simply doing this:
...and you can iterate through the .Items collection to do what you like with the buttons, however the DropDownItems collection for the export button always appears empty.
So the easy solution is to get rid of the default export button and add your own with just the functionality you need. So in your form constructor:
Then all you need to do is to take care of the actual exporting:
请尝试这个:
HTH
Please try this:
HTH