user1382306
user1382306

Reputation:

Excel export JavaScript variable

I've used the jQuery version in this article, but I'd rather export a javascript variable in the form of a table than an actual table in the DOM.

Does anyone know how to modify that code to do that? That small snippet of code goes well beyond my limits.

Many thanks in advance!

Upvotes: 0

Views: 1637

Answers (1)

Shubhanshu Mishra
Shubhanshu Mishra

Reputation: 6700

The for loop is where all the action happens in that code:

for(var i=0; i<rowCount; i++) 
{   
    for(var j=0; j<colCount; j++) 
    {           
        str= myTableHead.getElementsByTagName("tr")[i].getElementsByTagName("th")[j].innerHTML;
        ExcelSheet.ActiveSheet.Cells(i+1,j+1).Value = str;
    }
}

}

So all you can do is assign your java-script object values instead of the value of str to the ExcelSheet.ActiveSheet.Cells(i+1, j+1).Value and that will solve it.

Upvotes: 1

Related Questions