Is it possible to trigger the export to Excel/PDF/Word by clicking on a button (or any other control except the one given by reportViewer). I managed to trigger the Print and PrintLayout by doing the PerformClick, but it doesn’t work with export (it is the 15th index in reportViewers ToolBar but when I try the same thing with Export, nothing happens). Is this because the Export is a DropDownButton? In that case how would I access its items (I listed every item in the toolBar by name and index number, the Export DropDownButton is listed but it’s items are not).
Thanks
To access the toolbar you need a FindToolbar function like the one in the question you posted. This is the C# version of that function:
After that you create a button control (or any other you want) and in it add this code:
Item 13 is the print preview, you can get the indexes of all buttons on the reportViewers ToolStrip by looping trough it and writing out the names of the items (there are 21 of them in total, but some of them are separators or labels). You can use this code to trigger any of them (except the Export, I think it has something to do with the fact that Export is a dropdown button, not the ordinary one). If you are interested, this is the code that exports the displayed report into .xls file:
Again, you can put it into a button_Click method or something similar. I havent tried it with other extensions (.pdf or .doc), but I think it should work just fine. You need to add the extension of the file you are trying to save to the path string or else you won’t be able to open the created file.
I hope this helps you solve your problem.