<Html>
<HEAD>
<TITLE>javascript從excel中讀取數(shù)據(jù)并顯示</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進程,關(guān)閉當(dāng)前瀏覽器后有效。
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white">
<SCRIPT LANGUAGE = JavaScript>
addfile();
</SCRIPT>
</BODY>
</HTML>
該文章在 2013/6/13 9:08:59 編輯過