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

Exporting Grid to excel but including client templates? Possible?

10 Answers 2095 Views
Grid
This is a migrated thread and some comments may be shown as answers.
License
Top achievements
Rank 1
License asked on 15 Oct 2013, 09:49 PM
I found out how to export a single grid to excel from the grid but how would you export a grid that contains client templates?  Is it even possible?

Thanks.....

10 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 17 Oct 2013, 01:17 PM
Hi,


Basically when exporting Grid data to excel the ClientTemplate would not be used to format the data as the "Excel" file is generated on the server side. If you need to format some of the columns then you should modify the server code to export that column formatted the same way as the client template.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kannyetta
Top achievements
Rank 1
answered on 03 Feb 2015, 09:53 PM
Hi, Is there an example on the server side code? I have the below for exporting the grid but I have not been able to find any examples to get the client templates across in the export.

 [HttpPost]
    public ActionResult ExcelExportSave(string contentType, string base64, string fileName)
    {
      var fileContents = Convert.FromBase64String(base64);
      return File(fileContents, contentType, fileName);
    }

Thanks!
0
Dimiter Madjarov
Telerik team
answered on 05 Feb 2015, 01:27 PM
Hi Kannyetta,


This is an old forum thread, in which the approach from the Excel export Code Library is discussed. Using this implementation, the user manually handles the export on the server side.

The new built in export to Excel functionality constructs the file on the client side. The server side proxy is only needed to serve the file to the user in legacy browsers

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Michael Warden
Top achievements
Rank 1
answered on 13 Aug 2015, 03:57 AM

I'm using the method found here, http://demos.telerik.com/kendo-ui/grid/excel-export, but it's still not exporting the field as it appears after i modify it in a client template.  Is it supposed to be?

 I have a bound column with a client template that strings together first name and last name...

 #=Lastname#, #=FirstName#

 but it doesn't actually export like that.

0
Dimiter Madjarov
Telerik team
answered on 13 Aug 2015, 08:37 AM

Hello Michael,

Templates are not exported out of the box, because they may contain HTML entities that cannot be converted to HTML values. Since this does not seem to be the current case, you could use the following approach to include the template in the exported sheet.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 03 Dec 2017, 12:59 PM

So how can I do it?

I want to export only one column like the way it appears to me at clientTemplate?

thanks

0
Tsvetina
Telerik team
answered on 05 Dec 2017, 04:38 PM
Hello Michael,

The Kendo UI export can export text-only content to Excel. If your template results in a text string that you want to export, the approach shown in the article that Dimiter linked to should work for exporting it:
Use Column Template

You can also check this KB article, which shows what is the result of exporting various template columns:
Export to Excel Grids with Multiple Column Templates and Arbitrary Template Content

Regards,
Tsvetina
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
Ezequiel
Top achievements
Rank 2
answered on 17 Jan 2019, 01:14 PM

Hi Tsvetina,

I followed this:

[quote]
Use Column Template
[/quote]I followed this 

My Grid is paged, it only works for the first 50.

1.let data = event.sender.dataSource.view();
2.for (var i = 0; i < data.length; i++) {
3.      sheet.rows[i + 1].cells[bugColumnIndex - 1].value = bugTemplate(data[i]);
4.}

I even replaced line 1 with:

let data = event.sender.dataSource.data();

but both have only 50 items.

It exports all data, but applies the template only for these 50 items.

How to solve this?

0
Tsvetina
Telerik team
answered on 21 Jan 2019, 11:20 AM
Hi,

This behavior can be observed if your Grid uses server-side paging (the default behavior for the MVC Grid). The example takes the data items for the templates from the DataSource, but the DataSource keeps only the data needed to populate the Grid current page, not the export data. To fix this, you can use the e.data argument instead:
function exportGridWithTemplatesContent(e){
  var data = e.data;

http://dojo.telerik.com/@tsveti/EfoSUNim

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ezequiel
Top achievements
Rank 2
answered on 21 Jan 2019, 01:19 PM

Thank you! 

That worked.

Tags
Grid
Asked by
License
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Kannyetta
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Michael Warden
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Tsvetina
Telerik team
Ezequiel
Top achievements
Rank 2
Share this question
or