title: Create and download data as excel multiple sheets using JavaScript
body: <p>I am trying to create the data manually and then downloading as excel. Following is my code which is working fine:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
      &lt;a href='#' onclick='clickMe();'&gt;Download Excel&lt;/a&gt;
          &lt;script&gt;
              var clickMe = function(data,event) {
                  var excel = generate();
                  download(excel);
              }
  
              var generate = function(){
                  console.log('excel file exported');
                  // EXTRACT VALUE FOR HTML HEADER. 
                  var columns= [ 'name', 'desc', 'id','createdOn' ];
                  var qrows = [
                      ['Foo', 'programmer','1234','12 Apr 2017 12:34:55'],
                      ['Bar', 'bus driver', '2345','13 Apr 2017 12:34:55'],
                      ['Moo', 'Reindeer Hunter', '3456','14 Apr 2017 12:34:55']
                  ];
  
                   // CREATE DYNAMIC TABLE.
                  var table = document.createElement("table");
                  table.border = '2px solid black';
  
                  // CREATE HTML TABLE HEADER ROW USING THE EXTRACTED HEADERS ABOVE.
                  var tr = table.insertRow(-1); // TABLE ROW.
  
                  var col = columns.map(function(qcol){
                  var th = document.createElement("th"); // TABLE HEADER.
                  th.bgColor ="#a5a5da";
                  th.innerHTML = qcol.toUpperCase();
                  tr.appendChild(th);
                  return tr;
              });
  
              var rows = qrows.map(function(qrow, index){
                      tr = table.insertRow(-1);
                      qrow.forEach(function(row){
                      var cell = tr.insertCell(-1);
                      cell.innerHTML = row;
                  });
                      return tr;
                  });
  
                  return table;
              }//generate ends
  
              var download = function(content, fileName = 'exportExcel.xls', mimeType = 'application/vnd.ms-excel') {
                  const a = (document &amp;&amp; document.createElement('a')) || {};
  
                  if (typeof navigator != 'undefined' &amp;&amp; navigator.msSaveBlob) { // IE10
                      navigator.msSaveBlob(new window.Blob([ content ], { type: mimeType }), fileName);
  
                      } else if (typeof window.URL != 'undefined' &amp;&amp; 'download' in a) { // html5
                      var table_html = content.outerHTML.replace(/ /g, '%20');
                      a.href = 'data:' + mimeType + ', ' + table_html;
                      a.setAttribute('download', fileName);
                      document.body.appendChild(a);
                      a.click();
                      document.body.removeChild(a);
                  } else {
                      window.open('data:' + mimeType + ', ' + window.encodeURI(content));
                  }
              }//download ends
  
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the jsfiddle for it - <a href="https://jsfiddle.net/5oxptwh7/2/" rel="nofollow noreferrer">https://jsfiddle.net/5oxptwh7/2/</a></p>
  
  <p>I want to add a new sheet and add some data using javascript. KIndly, guide me on how can I achieve this in my above code</p>