This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 41066
    
  43
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: 41066
    
  43
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to export data to excel file in java script
 
Similar Threads
merge first row of excel sheet by javascript
passing java array to javascript
diasbling the parent window, until pop-up is closed
how to export data to Excel
How to Export Data from JSP to Excel