I am trying to export my Kendo grid to excel. It works fine except the formatting is missing. I think it is because I am using a template.
The Telerik documentation explicitly states:
To format the cell values during the export of the Grid to Excel, set the format option of the cells.
I have tried this and it is not working:
columns: [
{
field: "EntryWage",
headerTemplate: entryLevelWageColumnHeading + "<span name='EntryWage' class='k-icon k-i-close remove' style='float: right;'></span>",
width: 125,
attributes: { style: "text-align:right;" },
format: "{0:c}",
template: "#= (EntryWage != null) ? kendo.toString(EntryWage, 'C') : 'N/A' #"
}];
I also have this function (for excel grid defintiion):
excelExport: function (e) {
var sheet = e.workbook.sheets[0];
var row = sheet.rows[0];
$("#grid .k-grid-header .k-link").each(function (index) { //for each column header in the grid...
row.cells[index].value = $(this).text(); //set cell text from grid column text
row.cells[index].background = "#0070C0"; //set cell to "blue" color
});
},
Do I need to parse each cell here? Am I doing something wrong? I would think this would be really simple, since the whole Export to Excel is straightforward??