Tuesday, 10 September 2013

HTML data to a specific excel spreadsheet

HTML data to a specific excel spreadsheet

I have an HTML code that will open a new excel spread sheet. I would like
for it to open a specific spreadsheet and keep adding data to it. Here is
the code:
<script>
function ToExcel(){
if (window.ActiveXObject){
var xlApp = new ActiveXObject("Excel.Application");
var xlBook = xlApp.Workbooks.Add();
var table=document.getElementById('inner_table')
//var tableCells=document.getElementById('inner_table').cells
var tableRows=document.getElementById('inner_table').rows
xlBook.worksheets("Sheet1").activate;
var XlSheet = xlBook.activeSheet;
xlApp.visible = true;
var xlRow = 1;
var xlCol = 1;
var R=0;
while(tableRows[R] != null)
{
var tableCells =tableRows[R].cells
var C = 0;
xlCol=1;
while(tableCells[C] != null)
{
XlSheet.cells(xlRow, xlCol).value = tableCells[C].childNodes[1].value;
xlCol++;
C++;
}
xlRow++;
R++;
}
XlSheet.rows.autofit;
XlSheet.columns.autofit;
}
}
</script>

No comments:

Post a Comment