<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>Excel导出 </title>
<script src="jquery.js" type="text/javascript"></script>
<script src="common.js" type="text/javascript"></script>
<link href="global.css" rel="stylesheet" type="text/css" />
<style media="print" type="text/css">
.Noprint
{
display: none;
}
.PageNext
{
page-break-after: always;
}
.tblPrint
{
border: none;
}
</style>
<style type="text/css">
table
{
margin-bottom: 0;
}
table th, td
{
border: 0;
}
#tbHaederText .th
{
border: 1px solid windowtext;
padding: 0cm 2pt 0cm 2pt;
background-color: #FFFFFF;
height: 20px;
font-weight: bold;
}
#tbHaederText .td
{
border: 1px solid windowtext;
}
</style>
<script language="javascript" type="text/javascript">
function PrintDoc() {
$(".s_close").remove();
window.print();
}
function ReTabColumn(_this) {
$("#tdheji").attr("colspan", parseInt($("#tdheji").attr("colspan") - 1));
TabColRemove(_this, false);
}
//jQuery移除Table列,isDellast:false最后一行不受影响;true最后一行受影响
//<th>标题<span class="s_close" style='color: Red; cursor: pointer' onclick='ReTabColumn(this)' title='隐藏当前列'>×</span></th>
function TabColRemove(_this, isDellast) {
if (isDellast) {
$(_this).parent().parent().parent().find("tr td:nth-child(" + ($(_this).parent().index() + 1) + ")").remove();
} else {
$(_this).parent().parent().parent().find("tr:not(:last-child)").find("td:nth-child(" + ($(_this).parent().index() + 1) + ")").remove();
}
}
//jQuery HTML导出Excel文件(兼容IE及所有浏览器)
function HtmlExportToExcel(tableid) {
$(".s_close").remove();
var filename = $('#lbl_innum_link').text();
if (getExplorer() == 'ie' || getExplorer() == undefined) {
HtmlExportToExcelForIE(tableid, filename);
}
else {
HtmlExportToExcelForEntire(tableid, filename)
}
}
//IE浏览器导出Excel
function HtmlExportToExcelForIE(tableid, filename) {
try {
var winname = window.open('', '_blank', 'top=10000');
var strHTML = document.getElementById(tableid).innerHTML;
winname.document.open('application/vnd.ms-excel', 'export excel');
winname.document.writeln(strHTML);
winname.document.execCommand('saveas', '', filename + '.xls');
winname.close();
} catch (e) {
alert(e.description);
}
}
//非IE浏览器导出Excel
var HtmlExportToExcelForEntire = (function() {
var uri = 'data:application/vnd.ms-excel;base64,',
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><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return fun�
Html导出Excel文件(兼容所有浏览器)
1星 需积分: 35 44 浏览量
2017-11-01
11:19:57
上传
评论
收藏 45KB ZIP 举报
ChinaLzw
- 粉丝: 834
- 资源: 167