I have a kendo grid and I can export its data into excel file without any problem. In my grid, some columns may be hidden because they do not have any value. However, I want
You can have columns in an array which defines hidden: true and then simply traverse through columns array and show/hide columns just before export as following:
function excelExport(e) {
if (!exportFlag) {
for(var i=0; i < columns.length; i++) {
if(columns[i].hidden)
e.sender.showColumn(i);
}
e.preventDefault();
exportFlag = true;
setTimeout(function () {
e.sender.saveAsExcel();
});
} else {
for(var i=0; i < columns.length; i++) {
if(columns[i].hidden)
e.sender.hideColumn(i);
}
exportFlag = false;
}
}