<script language="javascript">
function exportExcel(atblData)
{
if (typeof(EXPORT_OBJECT)!="object")
{
document.body.insertAdjacentHTML("afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>");
}
with (EXPORT_OBJECT){
DataType = "HTMLData";
HTMLData =atblData.outerHTML;
try{
ActiveSheet.Export("C:\\ExportFile.xls",0);
alert('导出EXCEL文档完毕');
}
catch (e)
{
alert('导出Excel表失败,请确定已安装Excel2000(或更高版本),并且没打开同名xls文件');
}
}
}
</script>
<center><input type="button" value="导出以上数据为Excel文档" onclick="exportExcel(tblData)" ID="Button1"
NAME="Button1"></center>
<table width="800" border="1" ID="tblData">
<tr align="center">
<td colspan="3">测试</td>
</tr>
<tr>
<td align="center">AAAAAA</td>
<td align="center">BBBBBBB</td>
<td align="center">CCCCCCC</td>
</tr>
<tr>
<td align="center">1000</td>
<td align="center">500</td>
<td align="center">500</td>
</tr>
</table>
function exportExcel(atblData)
{
if (typeof(EXPORT_OBJECT)!="object")
{
document.body.insertAdjacentHTML("afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>");
}
with (EXPORT_OBJECT){
DataType = "HTMLData";
HTMLData =atblData.outerHTML;
try{
ActiveSheet.Export("C:\\ExportFile.xls",0);
alert('导出EXCEL文档完毕');
}
catch (e)
{
alert('导出Excel表失败,请确定已安装Excel2000(或更高版本),并且没打开同名xls文件');
}
}
}
</script>
<center><input type="button" value="导出以上数据为Excel文档" onclick="exportExcel(tblData)" ID="Button1"
NAME="Button1"></center>
<table width="800" border="1" ID="tblData">
<tr align="center">
<td colspan="3">测试</td>
</tr>
<tr>
<td align="center">AAAAAA</td>
<td align="center">BBBBBBB</td>
<td align="center">CCCCCCC</td>
</tr>
<tr>
<td align="center">1000</td>
<td align="center">500</td>
<td align="center">500</td>
</tr>
</table>