简体   繁体   English

如何从javascript中的excel文件中获取数据?

[英]how to get the data from excel file in javascript?

Here i want to get the Data from Excel File by using upload file control.My Snippet is 在这里我想使用上传文件控件从Excel File获取数据。我的代码段是

 <script type="text/javascript">
   function my_function() {
       var Excel;
       Excel = new ActiveXObject("Excel.Application");
       Excel.Visible = false;
       return Excel.Workbooks.Open("C:\Users\admin\Desktop\Bennu.xlsx").ActiveSheet.Cells(l, i).Value;
   }
   var i = 1;
   var l = 1;

   do {
       a = my_function()

       if (a != null) {
           document.write("value is " + a + "&nbsp ;&nbsp ;&nbsp ;&nbsp ;");
           i++;
       }
       else {
           l++;
           i = 1;
           document.write("<br />");
       }

       b = my_function()
   } while (a != null || b != null);

When i run this on i didn`t get any thing 当我在上面运行时,我什么都没得到

There are several problems there, the chief amongst them being that you're using an ActiveX object. 那里有几个问题,其中最主要的是您正在使用ActiveX对象。 That will only work in IE, and only in old versions of it, only if the user has it enabled, and only if the page is running in a trusted/intranet zone. 仅当用户启用了IE,并且仅当页面在受信任/内联网区域中运行时,这才在IE中起作用,并且仅在IE的旧版本中起作用。 No browser other than IE supports ActiveX objects, and even IE doesn't anymore. 除了IE之外,没有其他浏览器支持ActiveX对象,甚至IE也不再支持。

Separately, using document.write after initial page load will wipe the page out. 另外,在初始页面加载后使用document.write将擦除页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM