0

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!

Community
  • 1
  • 1

1 Answers1

1

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.

Shubhanshu Mishra
  • 6,210
  • 6
  • 21
  • 23