JavaScript导出word excel文件
出处:http://www.jcwcn.com/article/2005/1210/javascript_17476.html
<HTML>
<HEAD>
<title>WEB页面导出为EXCEL文档的方法
</title>
</HEAD>
<body>
<BR>
<table id = "PrintA" width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor = "#61FF13">
<TR style="text-align : center;">
<TD>单元格A</TD>
<TD>单元格A</TD>
<TD>单元格A</TD>
<TD>单元格A</TD>
</TR>
<TR>
<TD colSpan=4 style="text-align : center;"><font color="BLUE" face="Verdana">单元格合并行A</FONT></TD>
</TR>
</TABLE>
<BR>
<table id = "PrintB" width="100%" border="1" cellspacing="0" cellpadding="0">
<TR style="text-align : center;">
<TD>单元格B</TD>
<TD>单元格B</TD>
<TD>单元格B</TD>
<TD>单元格B</TD>
</TR>
<TR>
<TD colSpan=4 style="text-align : center;">单元格合并行B</TD>
</TR>
</TABLE>
<br><br><br>
<input type="button" onclick="javascript:AllAreaWord();" value="导出页面指定区域内容到Word">
<input type="button" onclick="javascript:AllAreaExcel();" value="导出页面指定区域内容到Excel">
<input type="button" onclick="javascript:CellAreaExcel();" value="导出表单单元格内容到Excel">
<SCRIPT LANGUAGE="javascript">
//指定页面区域内容导入Excel
function AllAreaExcel()
{
var oXL = new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var sel=document.body.createTextRange();
sel.moveToElementText(PrintA);
sel.select();
sel.execCommand("Copy");
oSheet.Paste();
oXL.Visible = true;
}
//指定页面区域“单元格”内容导入Excel
 
相关文档:
--------------------------------------------------------------------------------
<body>
<mce:script type="text/javascript"><!--
document.write("如果显示了这段文字,那么您的浏览器支持 JavaScript!")
// --></mce:script>
<noscript>No JavaScript support!</noscript&g ......
function get_cookie(Name)
{
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0)
{
var offset = document.cookie.indexOf(search)
if (offset != -1)
{
&nbs ......
! 去除字符串两端空格的处理
如果采用传统的方式,就要可能就要采用下面的方式了
//清除左边空格
function js_ltrim(deststr)
{
if(deststr==null)return "";
var pos=0;
var retStr=new String(deststr);
if (retStr.lenght==0) return retStr;
while (retStr.substring(pos, ......
Javascript代码
<script>
var idTmr = "";
function copy(tabid){
var oControlRange = document.body.createControlRange();
oControlRange.add(tabid,0);
oControlR ......