Hi Team,
I want to know how to disable export to Excel(or csv or pdf) option on the Report Viewer when we right click on it?
Is there a option in the versions from 7.9.6?
Hi Team,
I want to know how to disable export to Excel(or csv or pdf) option on the Report Viewer when we right click on it?
Is there a option in the versions from 7.9.6?
To remove the entire popup menu:
from org.apache.commons.lang3.reflect import FieldUtils
reportViewer = event.source.parent.getComponent('Report Viewer')
FieldUtils.writeField(reportViewer, "popupMenu", None, True)
If you want more granular control, youâll have to dive into the popupMenu
field and modify the JMenu there.
Hi paul,
Thanks for your immediate response, But can you please tell me Where can i find/Run the scripts to make the adjustments.
Actually i want to disable only save as XLS Option from Report viewer.
Thanks
Rajesh
Hi Paul,
Can you send me the updated script below which only removes the Save as XLS option from the PopupMenu?
FieldUtils.writeField (reportViewer, âpopupMenuâ, None, True)
I donât have the code written, but hereâs what you would need to do:
FieldUtils.readField
to get the current value of the popupMenu
field, which will be a JPopupMenu
.getSubElements()
getComponent()
on each menu item, then check its defined text (getText()
)Thank you i will try this
Paul,
I have a project where the âExport to Excelâ option from the reporting pop-up menu is locking the customers computers. They have requested that the entire pop-up menu be disabled. I tried adding the code you suggested above to the onReportGenerated portion of the report viewer component, but it did not disable the menu.
Could you elaborate on where the code should be placed and if I need to install anything on the gateway computer to get this to work.
Thanks.
Put it on windowOpened
or internalFrameActivated
and change the component reference accordingly. You need it to run at least once as soon as the window starts up, so that the component has no popup menu - the onReportGenerated
function is probably firing too âlateâ in the process.
Thank you. internalFrameActivated did the trick.
I needed this functionality, so I wrote a little segment of code that will allow you to easily remove any of the right-click print options you donât want. You just need your reference to the Report Viewer and a collection of actionOptions that you want on the right-click menu (spelling and capitalization must be exact!) Based on PGriffithâs recommendation above.
from org.apache.commons.lang3.reflect import FieldUtils
actionOptions = ["Print", "Save as PDF", "Save as XLS", "Save as HTML", "Save as PNG"]
if len(actionOptions) <> 0:
popupMenu = FieldUtils.readField(reportViewer, "popupMenu", True)
menuItems = popupMenu.getSubElements()
for count in range(len(menuItems)-1, -1, -1):
if menuItems[count].text not in actionOptions:
popupMenu.remove(count)
Thanks for sharing this with us.
I am trying to have this working but keep getting the error:
note: I added the following line to reference the report viewer:
reportViewer = system.gui.getParentWindow(event).getComponentForPath(âRoot Container.My_Reportâ).name
any advise?
Thanks in advance
Drop the .name
; youâre referencing the component correctly, but then getting its name, instead of the component itself.
Thanks for the swift response, it is working now.