Calling Excel Export from a custom button (javascript): I would like to call the excel export function from my own button (from javascript). I want my button to do exactly what the built in excel export button does.
- Jqgrid Export To Excel Demo Javascript Download File
- Asp Export To Excel
- Jqgrid Export To Excel Demo Javascript Download
- Javascript Export To Excel File
I want to download the grid data in csv format , by looking at the link http://jsfiddle.net/hybrid13i/JXrwM/ and using JSONToCSVConvertor($('#reportGrid').jqGrid('getGridParam', 'data'),'Report',true);
you can download a csv file but its column name are variable names not label any idea how can i fix this , or there is another solution
Jqgrid Export To Excel Demo Javascript Download File
2 Answers
You can use $('#reportGrid').jqGrid('getGridParam', 'colNames')
to get column headers.
By the way you can use jQuery.extend to make copy of the data, returned from $('#reportGrid').jqGrid('getGridParam', 'data'), and then modify the data before calling of JSONToCSVConvertor
.
UPDATED: The object
which you get by $('#reportGrid').jqGrid('getGridParam', 'data')
is the reference to internal data
parameters. So it contains all what it should contains. To have less properties in the items of the data you should first make a copy of the object and the modify it like you want. For example to delete Id
property from all items of the data you can do the following:
UPDATED: One can use SheetJS, for example, to export data to Excel. See the demo https://jsfiddle.net/OlegKi/ovq05x0c/6/, created for the issue. The corresponding code of the Export to Excel button used in the demo is the following
OlegOlegThanks to Oleg and the man who posted http://jsfiddle.net/hybrid13i/JXrwM/ with little enhancement in it this is my final solution
Usage:
Asp Export To Excel
NOTE Please note that this solution will not work in IE