求ASP页表格导出为EXCEL文档的码!!!
有个JS写的,在HTML页能用,到ASP页下就不能用了.如下 :(要导出的数据是RecordSet生成的)
<html>
<head>
<SCRIPT LANGUAGE="javascript">
//指定页面区域内容导入Excel
function moveToExcel()
{
var oXL= new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var sel=document.body.createTextRange();
//PrintA是table的id
sel.moveToElementText(T1);
sel.select();
sel.execCommand("Copy");
oSheet.Paste();
oXL.Visible = true;
}
</SCRIPT>
</head>
<body>
<BR>
<table id = "T1" width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor = "#61FF13">
<TR style="text-align : center;">
<TD>单元格A</TD>
<TD>单元格A</TD>
</TR>
<TR>
<TD colSpan=2 style="text-align : center;"><font color="BLUE" face="Verdana">单元格合并行A</FONT></TD>
</TR>
</TABLE>
<input type="button" onclick="moveToExcel()" value="导出页面指定区域内容到Excel">
<body>
</html>