0

我有一个 HTML 代码,可以打开一个新的 Excel 电子表格。我希望它打开一个特定的电子表格并继续向其中添加数据。这是代码:

<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>
4

0 回答 0