Consider we are downloading page name, description in excel.
1. we need to declare which field to includes from list for excel download.
1 2 |
$scope.csvHeader = ['Page Name', 'Page Description']; $scope.csvDetails = ['PageName', 'PageDescription']; |
In html file. we are declaring 2 buttons. one is hidden. from shown button we will click to hidden button which will apply fiilter on data that comes from serverside.
1 2 |
<md-button class="md-raised md-primary" id="exportexcel" ng-show="false" type="button" ng-csv="PageList | PageSearchText:filterData:this" csv-column-order="$parent.csvDetails" csv-header="$parent.csvHeader" filename="PageList.csv">Export</md-button> <md-button class="md-raised md-primary" type="button" ng-click="GetPageListForExcel()">Export</md-button> |
1 2 3 4 5 6 7 8 9 10 |
$scope.GetMonetizationListForExcel = function () { var response = BusDevService.GetPageListForExcel();//fetching data from server side. response.then(function (data) { $scope.PageList = data.data.objExcelList; setTimeout(function () { document.getElementById('exportexcel').click(; here are clicking another button fro downloading excel. }, 0); }); }; |