This is a migrated thread and some comments may be shown as answers.

Capture exported file in code for multiple grids

6 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 10 Jul 2018, 08:53 PM

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
End Sub

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,

Sam

6 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 13 Jul 2018, 03:18 PM
Hi Sam,

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.

Regards,
Tsvetomir
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.


0
Sam
Top achievements
Rank 1
answered on 13 Jul 2018, 09:47 PM

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.

Thanks,

-Sam

 

 

0
Tsvetomir
Telerik team
answered on 17 Jul 2018, 08:07 AM
Hi Sam,

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. 

Regards,
Tsvetomir
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Sam
Top achievements
Rank 1
answered on 17 Jul 2018, 03:53 PM

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,

-Sam

0
Tsvetomir
Telerik team
answered on 19 Jul 2018, 09:09 AM
Hi Sam,

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.

Regards,
Tsvetomir
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Sam
Top achievements
Rank 1
answered on 19 Jul 2018, 04:17 PM
Sweet, thank you :)
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Sam
Top achievements
Rank 1
Share this question
or