//AutomateExcel方法是保存HTML中的表格数据到Excel
function AutomateExcel(){
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = document.all.excelTable; //data是表格的ID
var hang = table.rows.length;
//var lie = table.rows(0).cells.length;
// Add table headers going cell by cell.
for (i=0;i<hang;i++){
for (j=0;j<table.rows(i).cells.length;j++){
oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText;
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
function AutomateExcel(){
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = document.all.excelTable; //data是表格的ID
var hang = table.rows.length;
//var lie = table.rows(0).cells.length;
// Add table headers going cell by cell.
for (i=0;i<hang;i++){
for (j=0;j<table.rows(i).cells.length;j++){
oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText;
}
}
oXL.Visible = true;
oXL.UserControl = true;
}