Home > Web Front-end > JS Tutorial > js code to read local excel document data_javascript skills

js code to read local excel document data_javascript skills

WBOY
Release: 2016-05-16 18:16:37
Original
1120 people have browsed it
复制代码 代码如下:

<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>







以上代码在需要设置IE安全级别低才能正常运行,贴出来主要是可以学习这方面的技术
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template