在Excel导入中的angular度

我正在试图实现一个函数来从HTML文件中的Excel文件中获取表的值。

在我的excel-function.html中我有:

<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script> <div ng-controller="myCtrl"> <button ng-click="exportData()" ng-show="(items|filter:{selected: true}).length">Export</button> <br /> <table width="100%"> <thead> <tr> <th></th> <th>Name</th> <th>Date</th> <th>Terms</th> </tr> </thead> <tbody> <tr ng-repeat="item in items"> <td><input type="checkbox" ng-model="item.selected" /></td> <td>{{item.Name}}</td> <td>{{item.Date}}</td> <td><span ng-repeat="term in item.Terms">{{term}}{{!$last?', ':''}}</span></td> </tr> </tbody> </table> <div id="exportable" style="display:none"> <table width="100%"> <thead> <tr> <th>Name</th> <th>Date</th> <th>Terms</th> </tr> </thead> <tbody> <tr ng-repeat="item in items|filter:{selected: true}"> <td>{{item.Name}}</td> <td>{{item.Date}}</td> <td><span ng-repeat="term in item.Terms">{{term}}{{!$last?', ':''}}</span></td> </tr> </tbody> </table> </div> </div> 

在我的excel-export.directive.js中我有:

 function myCtrl($scope) { $scope.exportData = function () { var blob = new Blob([document.getElementById('exportable').innerHTML], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8" }); saveAs(blob, "Report.xls"); }; $scope.importData = function () { var obj = xlsx(file); } $scope.items = [{ "Name": "ANC101", "Date": "10/02/2014", "Terms": ["samsung", "nokia", "apple"] }, { "Name": "ABC102", "Date": "10/02/2014", "Terms": ["motrolla", "nokia", "iPhone"] }] } 

但我不知道如何获得在angular度的Excel文件。

我不知道应该怎么读取excel文件。

如何导入Excel文件,您是否可以将文件的值放在范围内。

几个月前,我遇到了同样的问题,我决定为此创build一个库。 你会检查出来吗? 我感谢您的反馈,并使我自己可以帮助您! https://github.com/Helvio88/angular-xlsx-model