我正在开发angular网站,我需要将表格数据导出为pdf。
我想使用jQuery数据表,因为它还增加了一些功能,如分页,搜索和排序,但在浏览器的控制台上收到此错误“错误:[$ injector:unpr]”,即使我不确定使用ng-table也会使它成为数据表或不。
我也尝试过使用jquery插件qazxsw poi,但它只生成单页pdf,如果表有更大的数据则失败。请帮忙和TIA。
Html: -
pdfmake
AngularJs: -
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-table/1.0.0/ng-table.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng-table/1.0.0/ng-table.min.js"></script>
<table id="myYealyGrid" ng-class="myYealyGridClass" class="table table-responsive gridtable" ng-table="yearly_Table">
<thead>
<tr>
<th>Customer Name</th>
<th>Year</th>
<th>Total Amount($)</th>
</tr>
</thead>
<tbody>
<tr ng-show="YearlyReport.length !=0" ng-repeat="reportrow in YearlyReport" ng-init="setTotal(reportrow)">
<td>{{reportrow.CustomerName}}</td>
<td>{{reportrow.Month}}</td>
<td>{{reportrow.TotalAmount}}</td>
</tr>
<tr ng-show="YearlyReport.length ==0">
<td><small class="nodata">No data found.</small></td>
<td></td>
<td></td>
</tr>
</tbody>
<tfoot>
<tr ng-show="YearlyReport.length !=0" class="bg-warning">
<td class="td-font-bold-custm">Total</td>
<td></td>
<td class="td-font-bold-custm">{{gridTotalAmount | number:2}}</td>
</tr>
</tfoot>
</table>
你可以使用$('#myYealyGrid')。DataTable();初始化您的数据表。
但是,当您将数据放入HTML表格时,请使用。
它会自动初始化您的Datatable。
尝试一下,让我知道它是否有效。