将网页中的表格导出到excel怎么实现?
bolm 2004-10-11 12:15:05 我用Excel的Application组件在客户端导出到Excel
代码如下:
<input type="button" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint">
-----------------------------------------------------------------------------------
<SCRIPT LANGUAGE="javascript">
<!--
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.outtable; 'outtable为需要导出的表的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<lie;j++)
{
oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText;
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
//-->
</SCRIPT>
为什么点击后没有反映。怎么解决,急!!!!!