- 浏览: 19109 次
- 性别:
- 来自: 西安
文章分类
最新评论
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>生成Excel</title>
<style>
<!--
table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:middle;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:常规;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
.xl24
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:.5pt solid black;}
.xl25
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl26
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl27
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl28
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl29
{mso-style-parent:style0;
mso-number-format:"\@";}
.xl30
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid black;}
.xl31
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;}
.xl32
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;}
.xl33
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;}
.xl34
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl35
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl36
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl37
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl38
{mso-style-parent:style0;
font-size:22.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:.5pt solid black;
layout-flow:vertical;}
.xl39
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl40
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;
white-space:normal;}
.xl41
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;}
.xl42
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;}
.xl43
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl44
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl45
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;
white-space:normal;}
.xl46
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;}
.xl47
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;}
.xl48
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl49
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:none;
white-space:normal;}
.xl50
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:.5pt solid windowtext;}
.xl51
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl52
{mso-style-parent:style0;
font-size:22.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid black;
border-left:.5pt solid black;
layout-flow:vertical;}
.xl53
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid black;
border-left:.5pt solid windowtext;}
.xl54
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid black;
border-left:none;}
.xl55
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid black;
border-left:none;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<script language="jscript">
function replaceHtml(replacedStr,repStr,endStr){
var replacedStrF = "";
var replacedStrB = "";
var repStrIndex = replacedStr.indexOf(repStr);
while(repStrIndex != -1){
replacedStrF = replacedStr.substring(0,repStrIndex);
replacedStrB = replacedStr.substring(repStrIndex,replacedStr.length);
replacedStrB = replacedStrB.substring(replacedStrB.indexOf(endStr)+1,replacedStrB.length);
replacedStr = replacedStrF + replacedStrB;
repStrIndex = replacedStr.indexOf(repStr);
}
return replacedStr;
}
//elTalbeOut 这个为导出内容的外层表格,主要是设置border之类的样式,elDiv则是整个导出的html部分
function htmlToExcel(elTableOut,elDiv){
try{
//设置导出前的数据,为导出后返回格式而设置
var elDivStrBak = elDiv.innerHTML;
//设置table的border=1,这样到excel中就有表格线 ps:感谢双面提醒
elTableOut.border=1;
//过滤elDiv内容
var elDivStr = elDiv.innerHTML;
elDivStr = replaceHtml(elDivStr,"<A",">");
elDivStr = replaceHtml(elDivStr,"</A",">");
elDiv.innerHTML=elDivStr;
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText( elDiv );
oRangeRef.execCommand("Copy");
//返回格式变换以前的内容
elDiv.innerHTML = elDivStrBak;
//内容数据可能很大,所以赋空
elDivStrBak = "";
elDivStr = "";
var oXL = new ActiveXObject("Excel.Application")
var oWB = oXL.Workbooks.Add ;
var oSheet = oWB.ActiveSheet ;
oSheet.Paste();
oSheet.Cells.NumberFormatLocal = "@";
//oSheet.Columns("D:D").Select
oXL.Selection.ColumnWidth =7
oXL.Visible = true;
oSheet = null;
oWB = null;
appExcel = null;
}catch(e){
alert(e.description)
}
}
</script>
</head>
<body link=blue vlink=purple class=xl29>
<p>
<INPUT type="button" value="导出" id="dcExcel" onClick="htmlToExcel(document.getElementById('elTableOut'),document.getElementById('elDiv'));">
</p>
<div id="elDiv">
<table x:str border=0 cellpadding=0 cellspacing=0 width=915 id="elTableOut" style='border-collapse:
collapse;table-layout:fixed;width:690pt'>
<col class=xl29 width=61 span=15 style='mso-width-source:userset;mso-width-alt:
1952;width:46pt'>
<tr height=19 style='height:14.25pt'>
<td colspan=3 rowspan=3 height=57 class=xl24 width=183 style='height:42.75pt;
width:138pt'>Ebase</td>
<td colspan=9 rowspan=3 class=xl26 width=549 style='border-bottom:.5pt solid black;
width:414pt'>2011年春夏2月浪游法国·法式田园表-梭织</td>
<td colspan=3 rowspan=2 class=xl27 width=183 style='border-right:.5pt solid black;
width:138pt'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
<td colspan=3 height=19 class=xl36 style='border-right:.5pt solid black;
height:14.25pt'>2010-年10月18日</td>
</tr>
<tr height=19 style='height:14.25pt'>
<td rowspan=29 height=494 class=xl38 style='border-bottom:.5pt solid black;
height:370.5pt'>斯文系列</td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
<td colspan=2 rowspan=15 height=266 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;height:199.5pt'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=0 style='display:none'>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>生成Excel</title>
<style>
<!--
table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:middle;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:常规;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
.xl24
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:.5pt solid black;}
.xl25
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl26
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl27
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:none;
border-bottom:none;
border-left:none;}
.xl28
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid black;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl29
{mso-style-parent:style0;
mso-number-format:"\@";}
.xl30
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid black;}
.xl31
{mso-style-parent:style0;
font-size:24.0pt;
font-family:"Lucida Sans Unicode", sans-serif;
mso-font-charset:0;
mso-number-format:"\@";
text-align:center;}
.xl32
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;}
.xl33
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;}
.xl34
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl35
{mso-style-parent:style0;
font-size:20.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl36
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl37
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl38
{mso-style-parent:style0;
font-size:22.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:.5pt solid black;
layout-flow:vertical;}
.xl39
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl40
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;
white-space:normal;}
.xl41
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;}
.xl42
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;}
.xl43
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:.5pt solid windowtext;
border-right:.5pt solid black;
border-bottom:none;
border-left:none;}
.xl44
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl45
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;
white-space:normal;}
.xl46
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:none;
border-left:.5pt solid windowtext;}
.xl47
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:none;
border-left:none;}
.xl48
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:.5pt solid windowtext;
white-space:normal;}
.xl49
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:none;
white-space:normal;}
.xl50
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:.5pt solid windowtext;}
.xl51
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid windowtext;
border-left:none;}
.xl52
{mso-style-parent:style0;
font-size:22.0pt;
font-weight:700;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid black;
border-left:.5pt solid black;
layout-flow:vertical;}
.xl53
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:none;
border-bottom:.5pt solid black;
border-left:.5pt solid windowtext;}
.xl54
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid windowtext;
border-bottom:.5pt solid black;
border-left:none;}
.xl55
{mso-style-parent:style0;
mso-number-format:"\@";
text-align:center;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid black;
border-left:none;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<script language="jscript">
function replaceHtml(replacedStr,repStr,endStr){
var replacedStrF = "";
var replacedStrB = "";
var repStrIndex = replacedStr.indexOf(repStr);
while(repStrIndex != -1){
replacedStrF = replacedStr.substring(0,repStrIndex);
replacedStrB = replacedStr.substring(repStrIndex,replacedStr.length);
replacedStrB = replacedStrB.substring(replacedStrB.indexOf(endStr)+1,replacedStrB.length);
replacedStr = replacedStrF + replacedStrB;
repStrIndex = replacedStr.indexOf(repStr);
}
return replacedStr;
}
//elTalbeOut 这个为导出内容的外层表格,主要是设置border之类的样式,elDiv则是整个导出的html部分
function htmlToExcel(elTableOut,elDiv){
try{
//设置导出前的数据,为导出后返回格式而设置
var elDivStrBak = elDiv.innerHTML;
//设置table的border=1,这样到excel中就有表格线 ps:感谢双面提醒
elTableOut.border=1;
//过滤elDiv内容
var elDivStr = elDiv.innerHTML;
elDivStr = replaceHtml(elDivStr,"<A",">");
elDivStr = replaceHtml(elDivStr,"</A",">");
elDiv.innerHTML=elDivStr;
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText( elDiv );
oRangeRef.execCommand("Copy");
//返回格式变换以前的内容
elDiv.innerHTML = elDivStrBak;
//内容数据可能很大,所以赋空
elDivStrBak = "";
elDivStr = "";
var oXL = new ActiveXObject("Excel.Application")
var oWB = oXL.Workbooks.Add ;
var oSheet = oWB.ActiveSheet ;
oSheet.Paste();
oSheet.Cells.NumberFormatLocal = "@";
//oSheet.Columns("D:D").Select
oXL.Selection.ColumnWidth =7
oXL.Visible = true;
oSheet = null;
oWB = null;
appExcel = null;
}catch(e){
alert(e.description)
}
}
</script>
</head>
<body link=blue vlink=purple class=xl29>
<p>
<INPUT type="button" value="导出" id="dcExcel" onClick="htmlToExcel(document.getElementById('elTableOut'),document.getElementById('elDiv'));">
</p>
<div id="elDiv">
<table x:str border=0 cellpadding=0 cellspacing=0 width=915 id="elTableOut" style='border-collapse:
collapse;table-layout:fixed;width:690pt'>
<col class=xl29 width=61 span=15 style='mso-width-source:userset;mso-width-alt:
1952;width:46pt'>
<tr height=19 style='height:14.25pt'>
<td colspan=3 rowspan=3 height=57 class=xl24 width=183 style='height:42.75pt;
width:138pt'>Ebase</td>
<td colspan=9 rowspan=3 class=xl26 width=549 style='border-bottom:.5pt solid black;
width:414pt'>2011年春夏2月浪游法国·法式田园表-梭织</td>
<td colspan=3 rowspan=2 class=xl27 width=183 style='border-right:.5pt solid black;
width:138pt'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
<td colspan=3 height=19 class=xl36 style='border-right:.5pt solid black;
height:14.25pt'>2010-年10月18日</td>
</tr>
<tr height=19 style='height:14.25pt'>
<td rowspan=29 height=494 class=xl38 style='border-bottom:.5pt solid black;
height:370.5pt'>斯文系列</td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl39 width=122 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;width:92pt'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=14 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
<td colspan=2 rowspan=15 height=266 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black;height:199.5pt'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
<td colspan=2 rowspan=15 class=xl41 style='border-right:.5pt solid black;
border-bottom:.5pt solid black'> </td>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=19 style='height:14.25pt'>
</tr>
<tr height=0 style='display:none'>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
<td width=61 style='width:46pt'></td>
</tr>
</table>
</body>
</html>
相关推荐
JavaScript 生成 Excel 文档 JavaScript 可以使用 ActiveXObject 来生成 Excel 文档,下面是详细的知识点: 1. 创建 Excel 应用程序对象 使用 `var XLObj = new ActiveXObject("Excel.Application");` 创建 Excel...
用javascript脚本生成excel文件的一些基本参数设置
`xlsx.full.min.js`是一个强大的库,它允许开发者在前端生成Excel文件并设置样式,极大地扩展了JavaScript处理Excel数据的能力。这个库的核心是XLSX库,它是一个用于读写电子表格文件(如.xlsx和.xls)的开源...
js生成Excel文件,方法和方法已加注释,原理也很简单,上手可用。 js生成Excel文件,方法和方法已加注释,原理也很简单,上手可用。 js生成Excel文件,方法和方法已加注释,原理也很简单,上手可用。 js生成Excel...
jquery.table2excel.js 可一键生成Excel表格,需要jQuery.js支持 详细使用方法可见我的博客 https://blog.csdn.net/weixin_42571089/article/details/108799543
js 实现 用JavaScript导出图像到Excel! 值得下载看看!资源免费,大家分享!!
接下来,我们转向JavaScript生成Excel文件。在浏览器环境中,我们可以使用`SheetJS`(也称为`xlsx`)库。`SheetJS`支持读写多种电子表格格式,包括XLSX和CSV。它提供了一套完整的API来操作单元格、行和列,以及设置...
在JavaScript(JS)环境中,实现Excel导出是一项常见的需求,特别是在Web应用中处理大量数据时。前后端分离的开发模式下,前端需要处理用户交互,包括数据导出,这就需要我们借助一些库或者API来实现。以下是一些...
本文将深入探讨如何使用纯JavaScript实现JSON格式数据到Excel文件的导出,同时支持多个Sheet页的导出。这个功能对于前端开发者来说,能够极大地提升用户体验,特别是在数据管理、分析和分享场景下。 首先,我们要...
javascript表格导出excel,支持chrome.
js 导出 Excel 【支持大量数据导出,亲测】、支持IE噢
它可能包含了将JSON对象结构化为Excel表格所需的逻辑,包括列名的映射、数据类型的转换以及生成Excel文件的XML格式内容。 "jquery.min.js"是著名的jQuery库的压缩版本,一个轻量级、高性能的JavaScript库,简化了...
1. 使用JavaScript库(如`XLSX`)在浏览器环境中生成Excel文件。 2. 动态数据处理,根据用户输入或其他条件实时添加或修改数据。 3. 结合其他库(如`jQuery`)简化前端操作。 4. 提供示例(`demo.html`)和文档(`...
在这个场景下,ExcelPackage库是一个非常实用的工具,它允许我们在服务端生成Excel文件,并且可以利用预先设计好的模板来快速填充数据,保持一致的格式。本文将详细介绍如何在ASP.NET中使用ExcelPackage在服务端生成...
在JavaScript世界中,生成各种统计图表是一项常见的任务,尤其在数据可视化领域。JavaScript库和框架提供了丰富的功能,使得开发者能够创建交互式、美观的图表,帮助用户更好地理解数据。本篇将详细介绍如何使用...
纯js导出EXCEL,生成的伪xls文件 支持中文 1,我用谷歌浏览器下载没有问题,可能会碰见下载文件没有后缀名的问题,另存就可以 2,还有另一种解决方案,就是修改base64编码,使其支持中文,下篇文件会列出
对于更复杂的需求,可能需要借助像` SheetJS `这样的库,或者考虑在后端处理。 总结起来,纯前端生成HTML表格到Excel文件主要涉及以下步骤: 1. 获取HTML表格数据。 2. 将数据转换为CSV格式。 3. 创建并触发模拟的...
JavaScript生成Excel文件通常不依赖浏览器原生功能,而是通过模拟Excel文件格式(如`.xls`或`.xlsx`)来实现。这些文件格式基于开放XML标准,可以通过创建XML结构并将其打包为ZIP文件来构建。常见的方法是创建一个...
在IT行业中,数据导出是一项...总的来说,"excel导出的js"这个话题涵盖了JavaScript生成Excel文件的技术,以及与Java后端交互的方式。通过学习和应用这些知识,开发者可以为用户提供方便的数据导出功能,提高工作效率。