用一个通用的JavaScript过程就可以了:
function ConvertToExcel(){
var xlApp,myWorkbook,myWordsheet;
try{
xlApp=new ActiveXObject("Excel.Application");
}
catch(e){
alert("无法启动Excel!/n/n"+e.message+"/n/n如果您确信您的电脑中已经安装了Excel,那么请在IE的Internet选项中将/"http://111.22.3.0/"加入到安全站点中。");
return false;
}
xlApp.Visible=true;
myWorkbook=xlApp.Workbooks.Add();
xlApp.DisplayAlerts=false;
myWorkbook.Worksheets(3).Delete();
myWorkbook.Worksheets(2).Delete();
xlApp.DisplayAlerts=true;
myWorksheet=myWorkbook.ActiveSheet;
var obj =do
cument.all.tags("table");
rowStart = 1
colStart = 1
for(x=0;x<obj.length;x++)
{
if(obj[x].id=="obj")
{
for (i=rowStart;
i<obj[x].rows.length;
i++)
{
for (j=colStart;
j<obj[x].rows(i).cells.length;
j++)
myWorksheet.Cells(i+1-rowStart,j+1-colStart).Value = obj[x].rows(i).cells(j).innerText;
}
rowStart += obj[x].rows.length + 3
}
}
myWorksheet.Columns("A:IV").AutoFit;
}