• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to export data to excel file in java script

 
geethareddy swarna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi every body,
This is geethareddy, any body can help me how to do thecode for export htamltable to excel using java script.. very urgent please help me.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript can't do that. You need to write server-side code (like a servlet) that generates XLS or CSV.
 
geethareddy swarna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ULF,
I got the out put by using this code, BUt i have to change IE browser internet options like in security->customlevel->enable initialization and activex, Is there any chance to do this with out enable that option.
function toExcel(){
var xls = new ActiveXObject("Excel.Application");
xls.visible = true;
xls.Workbooks.Add;
dojo.query(".dojoxGridRowTable").forEach(function(node,index){
var x = node.rows;
for (i = 0; i < x.length; i++) {
var y = x[i].cells;

//showMessage(y);
for (j = 0; j < y.length; j++) {
xls.Cells(i + 1+index, j + 1).Value = y[j].innerText;
}
}
});
}
please give me reply....
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActiveX controls are generally a security risk, and thus disabled. That's the price one needs to pay for using them.

By the way, you're aware that this code ties you to a single browser on a single operating system? Plus, the user would need to have Excel installed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic