AngularJS NG-网格导出到Excel的selectedItems [英] AngularJS ng-grid Export to Excel for selectedItems
问题描述
我们有一个NG-网格,其显示从REST服务检索到的数据。我想导出用户选择的行(启用NG格选择复选框)到Excel并打开出类拔萃。应用程序的当前行为是导出到Excel按钮调用来自NG-电网所选项目REST服务,并使用POI把数据导入Excel并返回Excel中。
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.
有没有更好的方法来做到这一点?该数据已经在浏览器中,有没有什么angularjs,jQuery的或JavaScript函数来做到这一点?
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?
推荐答案
有是CSV导出插件:<一href=\"https://github.com/angular-ui/ng-grid/tree/master/plugins\">https://github.com/angular-ui/ng-grid/tree/master/plugins
它可以通过将其添加到您的gridoptions很容易地添加,同时确保显示页脚。
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,
...
};
它导出所有记录:从你指定的grid.data。结果
It exports all your records from your specified grid.data.
[虽然您可以在选择对象通过指定列等没有一个选项目前以限制selectedItems]结果
[Although you can pass in an options object for specifying columns etc. there isn't an option currently to limit to selectedItems.]
这看起来很容易,虽然调整了,而不是grid.mySelections在grid.data的NG-电网的CSV export.js源循环。 (不是我测试过)
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)
这篇关于AngularJS NG-网格导出到Excel的selectedItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!