GeeCON Prague 2014*
The moose likes Servlets and the fly likes how to export data to excel file in java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "how to export data to excel file in java script" Watch "how to export data to excel file in java script" New topic
Author

how to export data to excel file in java script

geethareddy swarna
Greenhorn

Joined: Jul 02, 2011
Posts: 2


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
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
JavaScript can't do that. You need to write server-side code (like a servlet) that generates XLS or CSV.


Ping & DNS - my free Android networking tools app
geethareddy swarna
Greenhorn

Joined: Jul 02, 2011
Posts: 2
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
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
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.
 
GeeCON Prague 2014
 
subject: how to export data to excel file in java script