admin管理员组

文章数量:1313275

We have a ng-grid which displays data retrieved from a rest service. I want to export the rows selected by user(ng-grid selection check box enabled) to an excel and open that excel. The current behavior of app is Export to excel button calling a rest service with selected items from ng-grid and using POI to put the data into excel and returning the excel.

Is there a better way to do this? The data is already in browser, is there any angularjs, jQuery or javascript function to do this?

We have a ng-grid which displays data retrieved from a rest service. I want to export the rows selected by user(ng-grid selection check box enabled) to an excel and open that excel. The current behavior of app is Export to excel button calling a rest service with selected items from ng-grid and using POI to put the data into excel and returning the excel.

Is there a better way to do this? The data is already in browser, is there any angularjs, jQuery or javascript function to do this?

Share Improve this question asked Oct 9, 2013 at 4:53 AyanAyan 5454 gold badges9 silver badges20 bronze badges 1
  • Maybe this topic can help – Nikos Paraskevopoulos Commented Oct 9, 2013 at 6:57
Add a ment  | 

1 Answer 1

Reset to default 5

There is a plugin for csv export : https://github./angular-ui/ng-grid/tree/master/plugins

It can be easily added by adding it to your gridoptions, while making sure to display the footer.

 $scope.gridOptions = {
        data: ...,
        plugins: [new ngGridCsvExportPlugin()],
        showFooter: true,
        ...
      };

It exports all your records from your specified grid.data.

[Although you can pass in an options object for specifying columns etc. there isn't an option currently to limit to selectedItems.]

It looks easy though to adjust the ng-grid-csv-export.js source to loop over grid.mySelections instead over grid.data. (not tested by me yet)

本文标签: javascriptAngularJS nggrid Export to Excel for selectedItemsStack Overflow