I have written the code in .JS file to fetch the data from sharepoint list and display in html table.

Now to take my work for next level I need to export the html table to "Excel". The below code is working fine in google chrome,But I find no luck in IE browser

Can any one help me for what reasons the below code is not getting execute


  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
$(document).ready(function() {
  $("#btnExport").click(function(e) {

    //getting data from our table
    var data_type = 'data:application/vnd.ms-excel';
    var table_div = document.getElementById('table_wrapper');
    var table_html = table_div.outerHTML.replace(/ /g, '%20');

    var a = document.createElement('a');
    a.href = data_type + ', ' + table_html;
    a.download = 'exported_table_' + Math.floor((Math.random() * 9999999) + 1000000) + '.xls';

  <button id="btnExport">Export to xls</button>
  <br />
  <br />
  <div id="table_wrapper">
    <table border="1" cellspacing="0" bordercolor="#222" id="list">
        <tr class="header">


  • Why build the html when you can directly build the Excel file? For example with: xlsx.js Commented Apr 12, 2016 at 9:50
  • I am using the above JavaScript in my js.file .Using the html file for presenting in stack echange. My problem is with above javascript which is not working in IR browser
    – MSA
    Commented Apr 13, 2016 at 6:21
  • No the above code requíres the html otherwise you will get a empty Excel file. Which begs the qeustion why build the html and fetch when you can just build the Excel directly. Commented Apr 13, 2016 at 6:57
  • can you please suggest is any alternative way to use in .js which helps in exporting the html table data in excel
    – MSA
    Commented Apr 13, 2016 at 8:00
  • can you use ActiveX? Commented Apr 29, 2016 at 21:06

1 Answer 1


a.download is not supported in IE and Mozilla browser.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.