View Full Version : Urgent: Export to Excel - IE7

22 Nov 2010, 10:59 AM
We have IE7 as a corporate standard. We are evaluating ExtJS and found it does not have an export from grid to Excel feature. Especially googling has resulted in no good examples for exporting a grid in IE7.
This is urgent and is a make or break for going ahead with ExtJS.
Can some one please help out with specific code/example/plugin? (and please no FF or IE8 examples)


22 Nov 2010, 11:19 AM
You always have the option to build the Excel file on the server and pass it to the user.

22 Nov 2010, 11:41 AM
We do not want to go for another library to do just the export - we are currently using a table library(displaytag) that already has this feature. We are trying to migrate to ExtJS since we like some of the other grid features it provides. Also we are planning to use the client side filtering that saki has written - so a client side export will be great but not necessary.

22 Nov 2010, 12:48 PM
Do you realize that Ext JS is an entirely client side JavaScript library, and not a Java library like the one you mentioned?

22 Nov 2010, 9:51 PM
Anybody has a good solution to the export to excel from client side?
...much appreciated!

23 Nov 2010, 2:21 AM
Hi, i use two methods, one is IE only (also v7) and uses ActiveX

function toExcel(grid){
if (window.ActiveXObject){
var xlApp = new ActiveXObject("Excel.Application");
xlApp.Visible = true;
var xlBook = xlApp.Workbooks.Add();
var XlSheet = xlBook.activeSheet;
xlApp.visible = true;
var xlRow = 1;
var xlCol = 1;
var store = grid.getStore();
for (xlCol=1;xlCol<store.fields.length+1;xlCol++){
var veld = store.fields.itemAt(xlCol-1).name;
XlSheet.cells(xlRow, xlCol).value = veld;
xlRow = 2;
store.each(function(record) {
for (xlCol=1;xlCol<record.fields.length+1;xlCol++){
var veld = store.fields.itemAt(xlCol-1).name;
XlSheet.cells(xlRow, xlCol).value = record.get(veld);

The other one is making a CSV textfile and then opening that with Excel. Use .csv as extension and Exel knows what to do with it.
I use ; as separator but you might have to see what you need in your windows language and region settings.

Success !


23 Nov 2010, 4:26 AM

for only serversided excel-creation i used successfully this script:

works great for me, hope for you, too.


23 Nov 2010, 7:46 AM
This user asked for IE7 support. The Exporter UX uses data url's, which are not supported by IE7.

23 Nov 2010, 8:29 AM
oh i see... sorry have not read right... :)

another idea we allready used is to fake an excel-file... it's realy a bad workaround, but it does what it should... you can create a csv-file. but instead of ';' or ',' you use '<tab>' to separate the fields. then you can name the file *.xls and excel will work fine with it...

for sure, you cant format anything and its realy NO excel-native. but for our customer the circumstance that is is called xls and behaves like one was enough, maybe it's for yours, too!?


23 Nov 2010, 9:46 AM
Thanks Peter - Excellent - I like the ActiveX option - but will have to discuss with larger team since people need to change their IE settings to be able to allow it to run.
Do you have the sample code for the CSV file?

6 Oct 2011, 7:51 AM
Hi, no i haven't, but is easy, you use the code above to build a string like
'"val1","val2"\r"val3","val4"' etc
The separator depends on your language setting in windows, is normally , or ;
The main problem in javascript is taht you have to write this to a separae window and the let the user save it since javascript can't write to disk.

Ik you use vbscript (IE only) you don't have this limitation, the string would be
"""val1"",""val2"""&VbCrLf&"""val3"",""val4" instead but i'm not sure if to do this you also wouldn't have to activate ActiveX

You save the file with the .csv extension and windows opens it as a xls(x) file with the fields in separate colums.
If you succeed, please post your code.