/** 导出Excel*/ var exportTab = (function() { var uri = 'data:application/vnd.ms-excel;base64,'; var template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head></head><body><table>{table}</table></body></html>'; var base64 = function(s) {return window.btoa(unescape(encodeURIComponent(s))) }; var format = function(s, c) {return s.replace(/{(\w+)}/g,function(m, p) {return c[p]; }) }; var explorer = window.navigator.userAgent ; if (explorer.indexOf("MSIE") >= 0) { return function(table,name){ var curTbl = document.getElementById("listtable"); var oXL = new ActiveXObject("Excel.Application"); //创建AX对象excel var oWB = oXL.Workbooks.Add(); //获取workbook对象 var oSheet = oWB.ActiveSheet; //激活当前sheet var Lenr = curTbl.rows.length; //取得表格行数 for (i = 0; i < Lenr; i++) { var Lenc = curTbl.rows(i).cells.length; //取得每行的列数 for (j = 0; j < Lenc; j++) { oSheet.Cells(i + 1, j + 1).value = curTbl.rows(i).cells(j).innerText; //赋值 } } oXL.Visible = true; //设置excel可见属性 } }else{ return function(table, name) { if (!table.nodeType) table= document.getElementById(table) var ctx = {worksheet: name|| 'Worksheet', table: table.innerHTML} alert(table.innerHTML); window.location.href = uri+ base64(format(template, ctx)) } } })();
详细解决方案
兼容红狐 IE 的-导出Excel
热度:199 发布时间:2013-10-12 11:54:04.0
相关解决方案
- 导出 Excel 资料怎样命名
- word excel pdf在ie浏览器中打开,该如何解决
- 在浏览器中展示word,excel.ppt,pdf等各种文件
- POI 处置 Excel,读取Excel中的格式 如表格框,背景色
- jxls 怎么导出图片到 excel 中
- poi excel 如何合并单元格?
- 用Java EXCEL API 是否能从Excel中导出表格,该如何处理
- java excel 問題 求大神 速解解决方案
- java 处理 excel 相关有关问题
- 求Microsoft.Office.Interop.Excel.dll 11.0.0.0解决方法
- Microsoft.Office.Interop.Excel.dll 导出的文件版本的有关问题
- VC 2010 怎么 操作 excel 了
- 小弟我用水晶报表9新建一个报表,采用PULL模式,在创建新的连接中选用access/Excel(DAO),选择数据库之后,总是弹出对话框说登录失败
- [Crystal Reports]在ASP.net web中导出 有关问题[Excel、Word、PDF]
- Excel 图表解决方法
- asp.net 导出 包孕样式的 excel
- 使用FlashPrinter将word,excel,pdf转换成swf失败的有关问题
- DataSet 读写 Excel.该怎么处理
- excel 导入数据到sql。就出有关问题了
- asp.net 导出(上载)Excel xp、win7 兼容
- .net 操作office(excel、word)咋搞?解决方法
- 怎的把Microsoft.Office.Interop.Excel.ApplicationClass excel创建的文件保存到数据流中
- asp.net上载并保存 excel 格式表格数据
- 64位操作系统能否使用 Microsoft.ACE.OLEDB.12.0 查询2003及以上的 Excel
- 后台下传文档,不限类型(doc,excel,txt都可以),前台上载的时候转换为PDF
- 高分分提问,excel 导出,提示CSS丢失有关问题
- 怎么实现在线显示word,excel,pdf,而不允许下载
- 怎么将gridview中的图片导出到word/excel?现在导出了其他数据列就差图片列了了
- 关于“Microsoft.Office.Interop.Excel.dll”的警告解决办法
- Excel 导入到DataSet,该如何处理