<Html> <HEAD> <TITLE>javascript从excel中读取数据并显示</TITLE> <SCRIPT LANGUAGE = JavaScript> function addfile(){ var exApp = new ActiveXObject("Excel.Application"); var exWBook = exApp.workbooks.open("c:\\001.xls") var exWSheet = exWBook.Worksheets(1); //document.write(""); var i=1,j=1; document.write("<table width=100%>"); while (exWSheet.Cells(i, j).Value != null) { document.write("<tr>"); while (exWSheet.Cells(i, j).Value != null) { document.write("<td>"); document.write(exWSheet.Cells(i, j).Value); document.write("</td>"); j=j+1; } i=i+1; j=1; document.write("</tr>"); } document.write("</table>"); exWBook.Close (savechanges=true); //exWSheet.Close(); //exApp.Close(); exApp.Quit(); exApp = null; //释放excel进程,关闭当前浏览器后有效。 } </SCRIPT> </HEAD> <BODY BGCOLOR="white"> <SCRIPT LANGUAGE = JavaScript> addfile(); </SCRIPT> </BODY> </HTML>