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

Export to a template Excel file

3 Answers 241 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Derrick
Top achievements
Rank 1
Derrick asked on 10 May 2016, 11:01 PM

Hello,

 

I was wondering if there is a way to export data from my RadGrid to an Excel File Template.  I am currently using Microsoft.Office.Interop.Excel and looping through my list to input each record in its according row and column but I am noticing it is running very slow now with the amount of records I have.   I believe this was a question asked in 2012 (http://www.telerik.com/forums/export-to-a-template-excel-file) and I am hoping it may now be supported.

 

Thank you

 

Derrick

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 May 2016, 01:33 PM
Hello Derrick,

The forum thread to which you referred is from the UI for ASP.NET AJAX forum. Since you are posting in the forum section for the UI for WPF suite, I suggest you taking a look at the Export section of RadGridView's online help.

Hope this helps.

Regards,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Derek
Top achievements
Rank 1
answered on 14 Jul 2020, 04:11 PM

I have the same question. I reviewed the Export section you linked in the previous response, but I can't seem to find where it addresses this question.

Our scenario is that we have a WPF app with many grids, and we've been successfully using the ExportToXlsx() method for years. But instead of exporting the grid to a brand-new, empty spreadsheet, we would like to be able to write to a file that was opened from an xlst template and then saved down to a different file location as xlsx.

So for example, the template would include a custom report header, a logo, and maybe additional stuff in the first 5 rows of the spreadsheet. Then the export would begin in row 6. Also, we'd need to be able to modifiy some of that "additional stuff" on the fly. For example, one requirement is to show a list of parameters that was used for this report, condensed into a row or two above the actual grid.

Is any of this possible?  If not with RadGridView.ExportToXlsx() method, then maybe with Telerik Reporting?

Thank you.

0
Martin Ivanov
Telerik team
answered on 16 Jul 2020, 10:43 PM

Hello Derek,

RadGridView export to Excel support works with the Telerik Document Processing Libaries. To achieve your requirement you can use the API of RadSpreadProcessing. I can suggest you to options:

  • Use the ExportToWorkbook method of RadGridView. This will generate a Workbook object which you can modify in order to create the final document.
  • Or instead of using the RadGridView export methods, you can iterate the data and manually create the document. This approach requires more effort to setup the document, collect the data and style the cells, but it comes with more flexibility, because you have full control over the created document. Also, the performance is better because in the common case you successively add the elements in the document. In the previous approach, you will have already generated document where you can insert elements where needed. The insert action in the RadSpreadProcessing library is time consuming operation.

I hope this helps. Also, if you have any questions about the Telerik Document Processing Libraries I would recommend you to open a new post (or a ticket) in the Document Processing forum.

Regards,
Martin Ivanov
Progress Telerik

Tags
GridView
Asked by
Derrick
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Derek
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or