用javascript将数据导入Excel示例代码

将数据导入Excel的方法有很多,本例介绍的这个是使用js来实现数据的导入,感兴趣的朋友可以了解下

网上收集的代码

<input type="button" value="导出到excel">

导出到Excel代码

<SCRIPT LANGUAGE="javascript"> <!-- function AutomateExcel() { // Start Excel and get Application object. var oXL = new ActiveXObject("Excel.Application"); // Get a new workbook. var oWB = oXL.Workbooks.Add(); var oSheet = oWB.ActiveSheet; var table = document.all.data; var hang = table.rows.length; var lie = table.rows(0).cells.length; // Add table headers going cell by cell. for (i=0;i<hang;i++) { for (j=0;j<lie;j++) { //oSheet.Cells(i+1,j+1).Font.Bold = True //oSheet.Cells(i+1,j+1).Font.Size = 50 //oSheet.Cells(i+1,j+1).Alignment = 2 oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText; } } oXL.Visible = true; oXL.UserControl = true; } //--> </SCRIPT>

<table> <tr> <td>&nbsp;姓名</td> <td colspan="2">年龄</td> <td>出生日期</td> </tr> <tr> <td>6</td> <td>25</td> <td colspan="2">8</td> </tr> <tr> <td>1</td> <td>2</td> <td colspan="2">4</td> </tr> </table>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgsfxx.html