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

Grid Export To Excel with Grouping

3 Answers 599 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Jul 2015, 02:50 PM

I am trying to export to excel using Kendo Grid with grouping enabled.  

When the data is exported without any grouping applied, the HTML encoding / decoding works as expected and the text is displayed correctly when I open up the spreadsheet in Excel. However when I group by a column whose value contains an apostrophe (or any character needing encoding), the grouped row is exported to excel without decoding the apostrophe which the users find unpleasant.

The grouping row is being auto-generated from Kendo MVC HTMLHelper for Grid and ​after reviewing the documentation regarding limitations around Kendo templates when exporting data to Excel.

What is the correct way to export a grid with grouping enabled -- in particular, how does one use Kendo Export To Excel functionality with grouping row values whose text contains characters ​​that must be HTML encoded? Is this functionality possible by default, or is custom code required to address this scenario when using ASP.NET MVC?

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 31 Jul 2015, 03:25 PM
Hello Andrew,

In this case I would suggest manually specifying the group header template, as this will generate a non-encoded string. Here is a JavaScript example illustrating the approach.

Regards,
Alexander Popov
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
Oli
Top achievements
Rank 1
answered on 12 Dec 2017, 07:12 PM

Is it possible to determine in the excelExport event whether the grid has been grouped?

I am customising the columns based on index (to overcome the Use Column Template issue as described here https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/excel/column-template-export).

It appears that the offset of the header columns with the data columns is affected once the grid has been grouped. As such, I need to amend the indexes accordingly. 

Please can you suggest a suitable approach.

0
Tsvetina
Telerik team
answered on 14 Dec 2017, 12:18 PM
Hi Oli,

You can check if there are any groups in the DataSource to determine if the Grid is grouped:
excelExport: function(e){
  if(e.sender.dataSource.group().length > 0){
    // grid is grouped
  }
}


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.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Oli
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or