<div class="codetitle"> <span><a style="CURSOR: pointer" data="88717" class="copybut" id="copybut88717" onclick="doCopy('code88717')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code88717"> <br><script> <BR>function readThis(){ <BR>var tempStr = ""; <BR>var filePath= document.all.upfile.value; <BR>var oXL = new ActiveXObject("Excel.application"); <BR>var oWB = oXL.Workbooks.open(filePath); <BR>oWB.worksheets(1).select(); <BR>var oSheet = oWB.ActiveSheet; <BR>try{ <BR>for(var i=2;i<46;i++){ <BR>if(oSheet.Cells(i,2).value =="null" || oSheet.Cells(i,3).value =="null" ) <BR>break; <BR>var a = oSheet.Cells(i,2).value.toString()=="undefined"?"":oSheet.Cells(i,2).value; <BR>tempStr+=(" "+oSheet.Cells(i,2).value+ <BR>" "+oSheet.Cells(i,3).value+ <BR>" "+oSheet.Cells(i,4).value+ <BR>" "+oSheet.Cells(i,5).value+ <BR>" "+oSheet.Cells(i,6).value+"\n"); <BR>} <BR>}catch(e){ <BR>//alert(e); <BR>document.all.txtArea.value = tempStr; <BR>} <BR>document.all.txtArea.value = tempStr; <BR>oXL.Quit(); <BR>CollectGarbage(); <BR>} <BR></script> <br> <br><input type="file" id="upfile"><input type="button" onclick="readThis();" value="读取"> <br><br> <br><textarea id="txtArea" cols="50" rows="10"></textarea> <br> <br> </div> <br>以上代码在需要设置IE安全级别低才能正常运行,贴出来主要是可以学习这方面的技术