Reputation: 327
I have a grid with large number of records. I use filters to filter the data as required. But i want to export the filtered data to a excel sheet for further usage.
I went through some articles available but they seem different and not compatible with latest 4.2 version.
Please help me in achieving this in simple manner.
Thanks much!
Upvotes: 9
Views: 22476
Reputation: 19880
Successfully implemented this approach for Ext JS 4. To give it a flexibility of an abstract class, follow the instructions:
Replace all "this" function references to global function calls.
Add "grid" parameter to all functions starting with the entry one (downloadExcelXml()).
Replace the remaining "this" calls to grid references (as functions were expected to act inside a grid).
Now add this button in your grid constructor and call downloadExcelXml() as a handler like this:
exportButton = {
xtype: 'button',
text: 'xls',
listeners: {
click: function (button, event, eOpts) {
downloadExcelXml(
false,
"TableHeader",
eOpts.data.grid);
},
data: {
grid: this
}
};
Upvotes: 3
Reputation: 9533
For extjs < 4 http://edspencer.net/2009/11/24/ext-ux-exporter-export-any-grid-to-excel-or-csv/
For extjs >= 4 http://www.sencha.com/forum/showthread.php?136598-Export-store-to-Excel
Upvotes: 4
Reputation: 773
As far as I know this isn't possible without a Serverside implementation in a cross browser manner.
In theory you create a OpenXML document string by reading the current records from the store and encode it with base64. Then write this to a Data Uri
. The first that didn't allow inline data other then images is IE so this won't work for all IE browser version due to limitations like size and images only. This will be the reason why there are no up to date implementations.
Upvotes: 3