简体   繁体   中英

How to read excel files using plain javascript

I am trying to display excel sheet data in table format in web page. Currently I am able to read excel data from text area using following code

  function generateTable() {
      var data = $('textarea[name=excel_data]').val();
      console.log(data);
      var rows = data.split("\n");

      var table = $('<table />');

      for(var y in rows) {
          var cells = rows[y].split("\t");
          var row = $('<tr />');
          for(var x in cells) {
              row.append('<td>'+cells[x]+'</td>');
          }
          table.append(row);
      }

      // Insert into DOM
      $('#excel_table').html(table);
      }

Currently I have paste excel file into text area How can I modify above code so that I can directly select the excel file and display it without use of text area. I know solution using angular js or jquery. Can someone tell how to do it using plain javascript

在类似的情况下,请求业务部门将他们的电子表格导出为 .csv 文件比开发解析 .xlsx 的解决方案更容易。

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