怎么用js将excel中的数据读取后显示到网页中的表格

2020-07-01 体育 122阅读
以前读书的时候绝不会想到会用客户端脚本来实现这些功能,现在却一开始就要用上了,而且还觉得挺实用的。
参考《Windows脚本技术》,应该会有一点收获。
http://www.w3.org/1999/xhtml" >

Untitled Page</title><br /></head><br /><script language="javascript" type="text/javascript"><br />function importXLS(fileName)<br />{<br />objCon = new ActiveXObject("ADODB.Connection");<br />objCon.Provider = "Microsoft.Jet.OLEDB.4.0";<br />objCon.ConnectionString = "Data Source=" + fileName + ";Extended Properties=Excel 8.0;";<br />objCon.CursorLocation = 1;<br />objCon.Open;<br />var strQuery;<br />//Get the SheetName<br />var strSheetName = "Sheet1$";<br />var rsTemp = new ActiveXObject("ADODB.Recordset");<br />rsTemp = objCon.OpenSchema(20);<br />if(!rsTemp.EOF)<br />strSheetName = rsTemp.Fields("Table_Name").Value;<br />rsTemp = null<br />rsExcel = new ActiveXObject("ADODB.Recordset");<br />strQuery = "SELECT * FROM [" + strSheetName + "]";<br />rsExcel.ActiveConnection = objCon;<br />rsExcel.Open(strQuery);<br />while(!rsExcel.EOF)<br />{<br />for(i = 0;i<rsExcel.Fields.Count;++i)<br />{<br />alert(rsExcel.Fields(i).value);<br />}<br />rsExcel.MoveNext;<br />}<br />// Close the connection and dispose the file<br />objCon.Close;<br />objCon =null;<br />rsExcel = null;<br />}<br /></script><br /></head><br /><body><br /><input type="file" id="f" /><br /><input type="button" id="b" value="import" onclick="if(f.value=='')alert('请选择xls文件');else importXLS(f.value)" /><br /></body><br /></html><br />trackback:<a href="http://hi.baidu.com/netcorner/blog/item/4c35a818788f670635fa41d3.html" target="_blank" rel="nofollow noopener">http: </div> <div class="tags"> </div> <div class="clear"> <div class="shares"> <b>声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com</b> <div id="share" class="share-component social-share" data-sites="weibo,qzone,qq,wechat"> </div> </div> <div class="act"> <a href="JavaScript:" onclick="zan('923442937479199219')" class="zan" title="赞"> <i class="iconfont bx bx-like"></i> <span id="zan">0</span> </a> </div> </div> <div class="clear"></div> </div> <div class="ny-ad"> </div> <div class="ny-ad"> </div> <div class="like"> <h3 class="title">最新文章</h3> <div class="piclist likep"> <div class="li"> <div class="img"> <a href="https://w.sf024.com/info/1117071876672932339.html" title="有跆拳道女生全力踢我一脚吗?"> <img src="https://w.sf024.com/assets/img/default.jpg" alt=""> </a> </div> <a href="https://w.sf024.com/ask/12" class="cat">体育 </a> <h3> <a href="https://w.sf024.com/info/1117071876672932339.html" title="有跆拳道女生全力踢我一脚吗?">有跆拳道女生全力踢我一脚吗?</a> </h3> <div class="meta"> <span class="time"> <i class="iconfont bx bx-time"></i> 04-15 </span> <span class="views"> <i class="iconfont bx bx-show"></i> 337阅读 </span> </div> </div> <div class="li"> <div class="img"> <a href="https://w.sf024.com/info/127220857.html" title="非主流QQ昵称加上配的个性签名和空间签名档"> <img src="https://w.sf024.com/assets/img/default.jpg" alt=""> </a> </div> <a href="https://w.sf024.com/ask/12" class="cat">体育 </a> <h3> <a href="https://w.sf024.com/info/127220857.html" title="非主流QQ昵称加上配的个性签名和空间签名档">非主流QQ昵称加上配的个性签名和空间签名档</a> </h3> <div class="meta"> <span class="time"> <i class="iconfont bx bx-time"></i> 04-15 </span> <span class="views"> <i class="iconfont bx bx-show"></i> 144阅读 </span> </div> </div> <div class="li"> <div class="img"> <a href="https://w.sf024.com/info/1671040975720706267.html" title="体育、体操、武术或舞蹈的教材中,那些描述动作过程的简笔画小人是怎么制作的?有相关的软件吗?"> <img src="https://w.sf024.com/assets/img/default.jpg" alt=""> </a> </div> <a href="https://w.sf024.com/ask/12" class="cat">体育 </a> <h3> <a href="https://w.sf024.com/info/1671040975720706267.html" title="体育、体操、武术或舞蹈的教材中,那些描述动作过程的简笔画小人是怎么制作的?有相关的软件吗?">体育、体操、武术或舞蹈的教材中,那些描述动作过程的简笔画小人是怎么制作的?有相关的软件吗?</a> </h3> <div class="meta"> <span class="time"> <i class="iconfont bx bx-time"></i> 04-16 </span> <span class="views"> <i class="iconfont bx bx-show"></i> 173阅读 </span> </div> </div> <div class="clear"></div> </div> </div> <div class="ny-ad"> </div> </div> <div class="sidebar"> <div class="widget postlist"> <h3>猜你喜欢</h3> <ul class="hasimg"> <li> <a href="https://w.sf024.com/info/923442937479199219.html" title="怎么用js将excel中的数据读取后显示到网页中的表格" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="怎么用js将excel中的数据读取后显示到网页中的表格"> </a> <a href="https://w.sf024.com/info/923442937479199219.html" target="">怎么用js将excel中的数据读...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 07-01 </span><span> <i class="iconfont bx bx-show"></i> 122阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/525166046315239725.html" title="怎么用js将excel中的数据读取后显示到网页中的表格?" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="怎么用js将excel中的数据读取后显示到网页中的表格?"> </a> <a href="https://w.sf024.com/info/525166046315239725.html" target="">怎么用js将excel中的数据读...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 06-22 </span><span> <i class="iconfont bx bx-show"></i> 87阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/492745549056335532.html" title="MATLAB怎么读取excel文件中的数据" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="MATLAB怎么读取excel文件中的数据"> </a> <a href="https://w.sf024.com/info/492745549056335532.html" target="">MATLAB怎么读取excel文...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 08-11 </span><span> <i class="iconfont bx bx-show"></i> 107阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/524956010203551765.html" title="在excel中的VBA里如何使用批量读取控件(如文本框)中的数据。" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="在excel中的VBA里如何使用批量读取控件(如文本框)中的数据。"> </a> <a href="https://w.sf024.com/info/524956010203551765.html" target="">在excel中的VBA里如何使用...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 04-16 </span><span> <i class="iconfont bx bx-show"></i> 481阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/63120094.html" title="如何把一个或几个CSV文件中的数据读取到Excel表格中" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="如何把一个或几个CSV文件中的数据读取到Excel表格中"> </a> <a href="https://w.sf024.com/info/63120094.html" target="">如何把一个或几个CSV文件中的数...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 09-17 </span><span> <i class="iconfont bx bx-show"></i> 101阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/1832370078628649220.html" title="js读取excel 少第一行" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="js读取excel 少第一行"> </a> <a href="https://w.sf024.com/info/1832370078628649220.html" target="">js读取excel 少第一行...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 06-27 </span><span> <i class="iconfont bx bx-show"></i> 136阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/309802921900694084.html" title="js读取本地excel文件出现问题,这是咋回事" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="js读取本地excel文件出现问题,这是咋回事"> </a> <a href="https://w.sf024.com/info/309802921900694084.html" target="">js读取本地excel文件出现问...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 05-03 </span><span> <i class="iconfont bx bx-show"></i> 111阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/455546399.html" title="麻烦各位高手替我解答一下问题: 在matlab中我用xlsread读取excel中的数据,为什么总是出现下面的错误?" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="麻烦各位高手替我解答一下问题: 在matlab中我用xlsread读取excel中的数据,为什么总是出现下面的错误?"> </a> <a href="https://w.sf024.com/info/455546399.html" target="">麻烦各位高手替我解答一下问题: ...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 05-20 </span><span> <i class="iconfont bx bx-show"></i> 170阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/628958872145230204.html" title="js怎么获取 excel的数据" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="js怎么获取 excel的数据"> </a> <a href="https://w.sf024.com/info/628958872145230204.html" target="">js怎么获取 excel的数据...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 07-18 </span><span> <i class="iconfont bx bx-show"></i> 114阅读 </span> </p> </li> <li> <a href="https://w.sf024.com/info/1759618854107598948.html" title="怎么用python读取excel表格的数据" class="img"> <img src="https://w.sf024.com/assets/img/default.jpg" alt="怎么用python读取excel表格的数据"> </a> <a href="https://w.sf024.com/info/1759618854107598948.html" target="">怎么用python读取excel...</a> <p class="meta"> <span> <i class="iconfont bx bx-time"></i> 08-18 </span><span> <i class="iconfont bx bx-show"></i> 60阅读 </span> </p> </li> </ul> </div> </div> </div> </section><footer class="footer"> <div class="container"> <p class="copyright">COPYRIGHT 2013 - 2024 你问我答网®. ALL RIGHTS RESERVED. | <a href="https://beian.miit.gov.cn/" target="_blank">豫ICP备2020035127号</a></p> </div></footer><script> let search_type="1"; var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?752ceaa2e03e39366ceff9a414a1f6a7"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();</script> <script type="text/javascript" src="https://w.sf024.com/assets/js/jquery.share.min.js"></script> </body> </html>