js读取本地excel文档数据 2008-08-19 08:56 Kevin-wang 阅读(278) 评论(0) 编辑 收藏 举报 摘自:http://blog.csdn.net/sainery/archive/2008/08/18/2790491.aspx 浏览器:IE 安全设置:默认 代码: Code 1<script> 2function readThis(){ 3 var tempStr = ""; 4 var filePath= document.all.upfile.value; 5 var oXL = new ActiveXObject("Excel.application"); 6 var oWB = oXL.Workbooks.open(filePath); 7 oWB.worksheets(1).select(); 8 var oSheet = oWB.ActiveSheet; 9 try{10 for(var i=2;i<46;i++){11 if(oSheet.Cells(i,2).value =="null" || oSheet.Cells(i,3).value =="null" )12 break;13 var a = oSheet.Cells(i,2).value.toString()=="undefined"?"":oSheet.Cells(i,2).value;14 tempStr+=(" "+oSheet.Cells(i,2).value+15 " "+oSheet.Cells(i,3).value+16 " "+oSheet.Cells(i,4).value+17 " "+oSheet.Cells(i,5).value+18 " "+oSheet.Cells(i,6).value+"\n");19 }20 }catch(e){21 //alert(e);22 document.all.txtArea.value = tempStr;23 } 24 document.all.txtArea.value = tempStr;25 oXL.Quit();26 CollectGarbage();2728}2930</script>31<html>32<input type="file" id="upfile" /><input type="button" onclick="readThis();" value="读取">33<br>34<textarea id="txtArea" cols=50 rows=10></textarea>35</html>3637 分类 04-UI展现 相关文章: