js导出Excel
2009-11-08 20:56
316 查看
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>将Web页面中的数据导出到Excel</title> <link href="CSS/style.css" mce_href="CSS/style.css" rel="stylesheet"> </head> <body> <form name="form1" method="post" action=""> <table width="540" height="343" border="0" align="center" cellspacing="0" background="main.gif" > <tr align="center"> <td width="42" height="56" align="right" valign="bottom"><img src="add.gif" mce_src="add.gif" width="20" height="18"></td> <td width="243" height="56" align="left" valign="bottom" id="doctitle"> 2007年1月份工资报表</td> <td width="249" align="left" valign="bottom"> </td> </tr> <tr align="center"> <td height="24" colspan="3"> </td> </tr> <tr align="center"> <td colspan="3" valign="top"> <table width="90%" border="0" cellspacing="1" bgcolor="#000000" id="wage"> <tr> <td width="79" height="27" align="center" bgcolor="#efefef">员工名称</td> <td width="69" align="center" bgcolor="#efefef">奖金</td> <td width="104" align="center" bgcolor="#efefef">基本工资</td> <td width="63" align="center" bgcolor="#efefef">津贴</td> <td width="57" align="center" bgcolor="#efefef">扣除</td> <td width="93" align="center" bgcolor="#efefef">实发工资</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">wgh</td> <td width="69" align="center" bgcolor="#FFFFFF">200</td> <td width="104" align="center" bgcolor="#FFFFFF">1800</td> <td width="63" align="center" bgcolor="#FFFFFF">300</td> <td width="57" align="center" bgcolor="#FFFFFF">0</td> <td width="93" align="center" bgcolor="#FFFFFF">2300</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">sk</td> <td width="69" align="center" bgcolor="#FFFFFF">100</td> <td width="104" align="center" bgcolor="#FFFFFF">2100</td> <td width="63" align="center" bgcolor="#FFFFFF">210</td> <td width="57" align="center" bgcolor="#FFFFFF">5</td> <td width="93" align="center" bgcolor="#FFFFFF">2405</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">春</td> <td width="69" align="center" bgcolor="#FFFFFF">70</td> <td width="104" align="center" bgcolor="#FFFFFF">1700</td> <td width="63" align="center" bgcolor="#FFFFFF">100</td> <td width="57" align="center" bgcolor="#FFFFFF">10</td> <td width="93" align="center" bgcolor="#FFFFFF">1860</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">夏</td> <td width="69" align="center" bgcolor="#FFFFFF">100</td> <td width="104" align="center" bgcolor="#FFFFFF">1900</td> <td width="63" align="center" bgcolor="#FFFFFF">100</td> <td width="57" align="center" bgcolor="#FFFFFF">20</td> <td width="93" align="center" bgcolor="#FFFFFF">2080</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">秋</td> <td width="69" align="center" bgcolor="#FFFFFF">150</td> <td width="104" align="center" bgcolor="#FFFFFF">1600</td> <td width="63" align="center" bgcolor="#FFFFFF">100</td> <td width="57" align="center" bgcolor="#FFFFFF">0</td> <td width="93" align="center" bgcolor="#FFFFFF">1850</td> </tr> <tr> <td width="79" height="27" align="center" bgcolor="#FFFFFF">冬</td> <td width="69" align="center" bgcolor="#FFFFFF">200</td> <td width="104" align="center" bgcolor="#FFFFFF">1500</td> <td width="63" align="center" bgcolor="#FFFFFF">100</td> <td width="57" align="center" bgcolor="#FFFFFF">0</td> <td width="93" align="center" bgcolor="#FFFFFF">1800</td> </tr> </table> <p align="center"><a href="#" mce_href="#" onClick="outExcel();">导出到Excel</a></p> </td> </tr> </table> </form> </body> </html> <mce:script language="javascript"><!-- function outExcel(){ var table=document.all.wage; row=table.rows.length; column=table.rows(1).cells.length; var excelapp=new ActiveXObject("Excel.Application"); excelapp.visible=true; objBook=excelapp.Workbooks.Add(); //添加新的工作簿 var objSheet = objBook.ActiveSheet; title=objSheet.Range("D1").MergeArea; //合并单元格 title.Cells(1,0).Value =doctitle.innerHTML.replace(" ",""); //输出标题 title.Cells(1,1).Font.Size =16; for(i=1;i<row+1;i++){ for(j=0;j<column;j++){ objSheet.Cells(i+1,j+1).value=table.rows(i-1).cells(j).innerHTML.replace(" ",""); } } excelapp.UserControl = true; } // --></mce:script>
相关文章推荐
- HTML用JS导出Excel的五种方法
- 直接在客户端通过js导出excel的方法(不限浏览器,不必安装excel)
- js导出excel增加表头、mso-number-format定义数据格式
- js导出格式化的excel 实例方法
- JS导出excel插件总结
- jsp将table导出成excel+用js将table导出excel,中文乱码问题解决方案+action层导出excel
- php 导出成csv或是excel格式的js文件(带序号)
- Js 导出table内容到Excel的简单实例
- js导出excel
- js将html中的内容导出word、或者excel文件的方法
- js导出excel, 并解决文件名是随机的问题,兼容多个浏览器
- js导出excel
- 无服务端纯前台导出数据到Excel-JSExcelXML.js 使用指南
- js导出excel到客户端下载
- js 中导出excel 较长数字串会变为科学计数法
- js导出Excel
- HTML使用JS导出Excel(五种方法)
- EasyUI 结合JS导出Excel文件的实现方法
- js导出excel兼容各个主流浏览器
- js 中导出excel 较长数字串会变成科学计数法