CSDN博客

img satans18

将表格中的数据导出到EXCEL表中的

发表于2004/10/13 8:13:00  714人阅读

分类: ASP

<TABLE id="outtable" name="outtable">
<TR>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
</TR>
<TR>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
</TR><TR>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
</TR><TR>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
</TR><TR>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
 <TD>asdf</TD>
</TR>
</TABLE>
<input type="button" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint">
<SCRIPT LANGUAGE="javascript">
function AutomateExcel()
{
var oXL = new ActiveXObject("Excel.Application");
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var hang = outtable.rows.length;

var lie = outtable.rows(0).cells.length;

for (i=0;i<hang;i++)
{
for (j=0;j<lie;j++)
{
oSheet.Cells(i+1,j+1).value = outtable.rows(i).cells(j).innerText;
}

}
oXL.Visible = true;
oXL.UserControl = true;
}
</SCRIPT>

阅读全文
0 0

相关文章推荐

img
取 消
img