js读取本地excel文档数据
生活随笔
收集整理的這篇文章主要介紹了
js读取本地excel文档数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
摘自: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();
27
28}
29
30</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>
36
37
?
轉載于:https://www.cnblogs.com/NRabbit/archive/2008/08/19/1736209.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的js读取本地excel文档数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git 报错:was cached in
- 下一篇: Oracle中修改遇到“ORA-0005