简体   繁体   中英

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

 <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. 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. No browser other than IE supports ActiveX objects, and even IE doesn't anymore.

Separately, using document.write after initial page load will wipe the page out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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