title: Export data to xls using Angularjs in correct format
body: <p>I need to export data to an excel sheet using AngularJS(using version 1.5.x)
  I tried using FileSaver.js and Alasql from the solution given in the below link</p>
  
  <p><a href="https://stackoverflow.com/questions/21680768/export-to-xls-using-angularjs">Export to xls using angularjs</a></p>
  
  <p>I have two problems. </p>
  
  <ol>
  <li><strong>I need the data in excel to be customized as in below screenshot :</strong></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/QmCZc.png" rel="nofollow noreferrer">Format required</a></p>
  
  <p>The required bold headers and separate rows on the top of the table I could achieve using FileSaver, but it leads to the second point.</p>
  
  <pre><code>Javascript &amp; HTML Code -
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$scope.getFile = function () {
  var blob = new Blob([document.getElementById('exportable').innerHTML], {
      type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"});
      saveAs(blob, "ProgramsInfo.xls");
  }
  
  &lt;a ng-click="getFile()" file-download="myBlobObject"&gt;Download Report&lt;/a&gt;&lt;a&gt;Share&lt;/a&gt;
  &lt;div id="exportable" style="display:none;"&gt;
      &lt;table width="100%" border="1"&gt;
          &lt;thead&gt;
            &lt;tr&gt;&lt;td&gt;Client : {{client}}&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Program : {{programName}}&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Date Range : {{dateRange}}&lt;/td&gt;&lt;/tr&gt;
            &lt;tr&gt;
                &lt;th&gt;Name&lt;/th&gt;
                &lt;th&gt;E-mail&lt;/th&gt;
                &lt;th&gt;DoB&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr ng-repeat="program in programs"&gt;
                  &lt;td&gt;{{program.account_name}}&lt;/td&gt;
                  &lt;td&gt;{{program.e_mail ? 'Y':'N'}}&lt;/td&gt;
                  &lt;td&gt;{{program.dob | date:'MM/dd/yy'}}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <ol start="2">
  <li>Getting an error when using Firefox which states that <code>The file you are trying to open is in a different format than specified by the file extension...</code></li>
  </ol>
  
  <p>![] [Firefox Error message]<a href="https://i.stack.imgur.com/J8UyJ.png" rel="nofollow noreferrer">2</a></p>
  
  <p>Can anyone help me with this?</p>