title: Angular JS - How to export Javascript Object to XLS file ?
body: <p>Actually, I've an object in my controller, i just want to export that object as .xls or .csv file.i used a lot of approaches like this:</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript" /&gt;
  &lt;div ng-controller="myCtrl"&gt;
      &lt;button ng-click="exportData()"&gt;Export&lt;/button&gt;
      &lt;br /&gt;
      &lt;div id="exportable"&gt;
      &lt;table width="100%"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Email&lt;/th&gt;
                  &lt;th&gt;DoB&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr ng-repeat="item in items"&gt;
                  &lt;td&gt;{{item.name}}&lt;/td&gt;
                  &lt;td&gt;{{item.email}}&lt;/td&gt;
                  &lt;td&gt;{{item.dob | date:'MM/dd/yy'}}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function myCtrl($scope) {
      $scope.exportData = function () {
          var blob = new Blob([document.getElementById('exportable').innerHTML], {
              type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
          });
          saveAs(blob, "Report.xls");
      };
  
      $scope.items = [{
          name: "John Smith",
          email: "j.smith@example.com",
          dob: "1985-10-10"
      }, {
          name: "Jane Smith",
          email: "jane.smith@example.com",
          dob: "1988-12-22"
      }, {
          name: "Jan Smith",
          email: "jan.smith@example.com",
          dob: "2010-01-02"
      }, {
          name: "Jake Smith",
          email: "jake.smith@exmaple.com",
          dob: "2009-03-21"
      }, {
          name: "Josh Smith",
          email: "josh@example.com",
          dob: "2011-12-12"
      }, {
          name: "Jessie Smith",
          email: "jess@example.com",
          dob: "2004-10-12"
      }]
  }
  </code></pre>
  
  <p>but this not works with paginated tables.is there any way to directly export objects (In this example $scope.item ) to file (xls,csv) ? </p>