角度データテーブルのデータをExcelシートにエクスポートしようとしています。私はJsonオブジェクト全体をExcelシートにエクスポートするのに成功しています。フィルタリング/検索データを角度データテーブルからExcelにエクスポート
私が探しているのは、検索されたデータがExcelにエクスポートされるようにすることです。検索が空の場合は、すべてのデータをエクスポートします。参考のため
は私が私のコードは、これはこれは私のHTMLのDataTableとして
<div class="table-toolbar">
<div class="row">
<div class="col-md-6">
<div class="btn-group">
<button id="sample_editable_1_new" class="btn sbold green" ng-click="vm.exportData()">Export As Excel</button>
</div>
</div>
</div>
</div>
<div class="dataTables_wrapper no-footer">
<table class="table table-striped table-bordered table-hover dataTable" datatable="ng" id="sample_1">
<thead>
<tr>
<th> Sl. No. </th>
<th> Name </th>
<th> Email </th>
<th> Designation </th>
<th> Company Name </th>
<th> Status </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in vm.users">
<td> {{$index+1}} </td>
<td> {{user.fullName}} </td>
<td> {{user.email}} </td>
<td> {{user.designation}} </td>
<td> {{user.companyName}} </td>
<td>{{user.isActive === true? "Active" : "In-Active" }}
</td>
</tr>
</tbody>
</table>
は、機能を内蔵しているである私のコントローラ
userService.getUserList(function(response) {
if (response.status === 200) {
vm.users = response.data.userDetails;
return;
}
if (response.status === 400) {
return toastr.error(response.data.exception);
}
});
vm.exportData = function() {
vm.listOfUsers = angular.copy(vm.users);
vm.filteredData = _.map(vm.listOfUsers, function(data){
var status = (data.isActive==true)?'Active':'In-Active';
var users = {'Name': data.fullName, 'Email': data.email, 'Designation': data.designation, 'Company Name': data.companyName,'Status':status}
return users;
});
alasql('SELECT * INTO XLSX("download.xlsx",{headers:true}) FROM ?', [vm.filteredData]);
}
ある
でどのようにお見せしましょうユーザーが何かを入力すると検索が開始されるので、ユーザー検索ボタンをクリックすると、検索クエリに関連するデータだけを渡して、そのデータのみがExcelにエクスポートされるようにします。私は、解決策を見つけた
よりもむしろデータを印刷