AngularJS将数据表下载到CSV

时间:2018-10-01 09:39:57

标签: javascript html angularjs

有人可以教我如何将json中的数据表转换为PDF吗?我只能找到无法解释的代码。如果有人知道正确解释它的地方并与我分享,那将很酷。赞赏!

我的数据表示例:

            <table class="table table-striped table-hover">
              <thead>
                <tr>
                  <th ng-click="sort('id')">Name
                    <span class="glyphicon sort-icon" ng-show="sortKey=='id'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
                  </th>
                  <th ng-click="sort('first_name')">Block No.
                    <span class="glyphicon sort-icon" ng-show="sortKey=='first_name'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
                  </th>
                  <th ng-click="sort('last_name')">Postal Code
                    <span class="glyphicon sort-icon" ng-show="sortKey=='last_name'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
                  </th>
                  <th ng-click="sort('hobby')">Street Name
                    <span class="glyphicon sort-icon" ng-show="sortKey=='hobby'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr dir-paginate="audit in auditoriums|orderBy:sortKey:reverse|filter:search|itemsPerPage:5 | limitTo: 1 - auditoriums.length">
                  <td>{{audit.NAME}}</td>
                  <td>{{audit.ADDRESSBLOCKHOUSENUMBER}}</td>
                  <td>{{audit.ADDRESSPOSTALCODE}}</td>
                  <td>{{audit.ADDRESSSTREETNAME}}</td>
                </tr>
              </tbody>
            </table>

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此 Client-side JavaScript PDF generation

var doc = new jsPDF()
doc.text('Sample text', 11100221, 22,44)
doc.save('sampleText.pdf')