<!DOCTYPE html>
<html>

<head>
  <link data-require="bootstrap-css@*" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
  <script data-require="angular.js@1.3.15" data-semver="1.3.15" src="https://code.angularjs.org/1.3.15/angular.js"></script>
  <script data-require="ui-bootstrap@*" data-semver="0.13.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.min.js"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
  <script src="ng-table-to-csv.min.js"></script>
</head>

<body ng-app="ng-table-to-csv-demo">
  <div data-ng-controller="DemoCtrl">
    <h1>{{title}}</h1>
    <a class="btn" title="Export Table" ng-click="csv.generate()" ng-href="{{ csv.link() }}" download="myTable.txt">
      <i class="glyphicon glyphicon-new-window"></i> Export
    </a>
    <table class="table table-bordered" export-csv="csv" 
    separator=";" export-csv-ignore="ignore">
      <tr>
        <th>Entry Header 1</th>
        <th>Entry Header 2</th>
        <th>Entry Header 3</th>
        <th>Entry Header 4</th>
      </tr>
      <tr>
        <td>Entry First Line 1</td>
        <td>Entry First Line 2</td>
        <td>Entry First Line 3</td>
        <td>Entry First Line 4</td>
      </tr>
      <tr>
        <td>Entry Line 1</td>
        <td>Entry Line 2</td>
        <td>Entry Line 3</td>
        <td>Entry Line 4</td>
      </tr>
      <tr>
        <td>Entry Last Line 1</td>
        <td>Entry Last Line 2</td>
        <td>Entry Last Line 3</td>
        <td>Entry Last Line 4</td>
      </tr>
      <tr class="ignore">
        <td>Don't export me 1</td>
        <td>Don't export me 2</td>
        <td>Don't export me 3</td>
        <td>Don't export me 4</td>
      </tr>
    </table>
  </div>
</body>

</html>
// Code goes here

angular.module('ng-table-to-csv-demo', ['ngTableToCsv'])
.controller('DemoCtrl',['$scope',function($scope){
  $scope.title = "ng-table-to-csv";
}]);
/* Styles go here */

# [ng-table-to-csv](https://github.com/kollavarsham/ng-table-to-csv)

## Angular.js Module for exporting Tables to CSV

As opposed to [the forked library](https://github.com/esvit/ng-table-export), this version does not have a dependency on `ng-table` and can export any HTML table.

## Installation

With Bower:

```shell
bower install ng-table-to-csv --save
```

## Usage

Add `export-csv` attribute directive on the table to define a new `csv` object in the scope with `generate()` and `link()` functions on them. See below: 

```html
      <a class="btn" title="Export Table" ng-click='csv.generate()' ng-href="{{ csv.link() }}"
         download="myTable.csv">
        <i class="glyphicon glyphicon-new-window"></i> &#160;Export
      </a>
      <table class="table table-bordered" export-csv="csv">
        <!-- table contents -->
      </table>
```

#### License

MIT License - Copyright (c) 2015 The Kollavarsham Team

#### Original License

Code originally released under [New BSD License](https://github.com/esvit/ng-table-export/blob/master/LICENSE) by [@esvit](https://github.com/esvit) at [esvit](https://github.com/esvit)/[ng-table-export](https://github.com/esvit/ng-table-export).
!function(e){e.module("ngTableToCsv.config",[]).config(["$compileProvider",function(e){e.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|data):/)}]).value("ngTableToCsv.config",{debug:!0}),e.module("ngTableToCsv.directives",[]),e.module("ngTableToCsv",["ngTableToCsv.config","ngTableToCsv.directives"])}(angular),function(e){"use strict";e.module("ngTableToCsv.directives").directive("exportCsv",["$parse",function(n){return{restrict:"A",scope:!1,link:function(t,i,a){var r="",o=a.separator?a.separator:",",s=a.exportCsvIgnore||".ng-table-filters",l={stringify:function(e){return'"'+e.replace(/^\s\s*/,"").replace(/\s*\s$/,"").replace(/"/g,'""')+'"'},generate:function(){r="";var n=i.find("tr");e.forEach(n,function(n,t){var i=e.element(n),a=i.find("th"),c="";i.hasClass(s)||(0===a.length&&(a=i.find("td")),e.forEach(a,function(n,t){var i="";n=e.element(n),n.hasClass(s)||(i=e.element(n).text()),c+=l.stringify(i)+o}),c=c.slice(0,c.length-1),r+=c+"\n")})},link:function(){return"data:text/csv;charset=UTF-8,"+encodeURIComponent(r)}};n(a.exportCsv).assign(t.$parent,l)}}}])}(angular);