Angular JS - How to export Javascript Object to XLS file ?

前端 未结 2 1454
遥遥无期
遥遥无期 2021-01-12 15:14

Actually, I\'ve an object in my controller, i just want to export that object as .xls or .csv file.i used a lot of approaches like this:

HTML

<
2条回答
  •  滥情空心
    2021-01-12 16:00

    If you're satisfied with a CSV file, then the ngCsv module is the way to go. You don't load elements from the DOM but export an array directly. Here you can see a sample of ngCsv in action.

    The html:

     

    Export {{sample}}

    and the js:

    angular.module('csv', ['ngCsv']);
    
    function Main($scope) {
        $scope.sample = "Sample";
        $scope.getArray = [{a: 1, b:2}, {a:3, b:4}];                            
    }
    

提交回复
热议问题