We have client requirement to export multiple grids and produce a single spreadsheet with multiple tabs without user interaction (scheduled). So we're attempting to set the data source and the item data bound events in code with no problems, so the grid is completely setup correctly, but when we export and try to capture the exported file, we are unsuccessful. so here is my question: in a standard user driven asp.net page, we can access the exported file from here:
Private Sub Grid_GridExporting(ByVal source As Object, ByVal e As GridExportingArgs)
Dim ExportString = e.ExportOutput
is there a different way we can get the same file from the grid without triggering the event? I see some solutions that require us to go through the cells and copy each one to the worksheet, but this is no good because it's missing tons of stuff (like formatting). And it's already part of the functionality of the Grid to be able to export in a very clean manner, so i have hope that there might be a trick somewhere that i did not see. Something simple like: grid.GetHTMLSheet()
Thank you for all the help,
6 Answers, 1 is accepted
I have created a project sample which exports two separate RadGrid controls into one Excel file. I have used only one DataSource to populate both grids but the sample is created in such a way that it can handle different data sources and will always produce the desired output.
The crucial part of the whole functionality is to coordinate the export events of both grids. In order to export both tables in one Excel file, the Export Output of the first one has to be saved in a global Session variable and when the second export event is fired both export outputs have to be passed. This approach requires 2 PostBack operations.
As an alternative option, you can also check the following project: Three RadGrids Exported.
Thank you for the help, but unfortunately none of the two solution is what i'm attempting to create.
1. The code needs to be under App_Code directory, so no .aspx to help us at all, and this sometimes prevents certain events from firing
2. Traversing the cells of the grid to create the sheet is extremely limited - missing all the formatting and the cool stuff we have in the Grid
3. You already have the ability in the Grid to produce the exported sheet, how do we trigger that without the export events having to take place
4. Please imagine the grids (35 of them and growing) we're creating are extremely complex, trying to export the same format by hand would create a mutiny :)
I appreciate all the help here because the alternative solutions are very ugly to implement.
I am afraid that this requirement is not supported out of the box by the RadGrid control. The exporting internal logic of the grid to generate the e.ExportOutput is not exposed.
Essentially, you can achieve this by creating the table structure manually using a similar approach to the demonstrated implementation in the SDK sample provided in my previous post, but this is rather a custom implementation and is beyond our support scope.
Sorry to hear that - yes of course we can do it by hand, but this is why we have these controls :) Would you please consider this as a request for enhancement, especially that you do it already in a different way. This would totally make sense to be available in this manner.
Thank you for this idea. I have created a public feature request in our Ideas & Feedback Portal - Expose ExportOutput Feature Request.
If you have any further queries, do not hesitate to contact us.