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 even these hidden columns (I mean their header) be in my exported excel file.
Here is a piece of code showing the excel config in my Kendo grid configuration.
excel: {
fileName: new Date().toString() + ".xlsx",
allPages: true,
},
Any help would be appreciated.
You can add some javascript to control this.
Basically this catches the
excelExport
event when you click the Export button and shows the hidden column in your grid before it fires thesaveAsExcel()
function which saves your document. Then it hides the column again.Here is an Example you can test with.
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:
I was looking to achieve a similar thing and used the answer provided by @Ankur with slight modification as I needed to hide the columns again after the export.
Code as follows: