在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
- 将Angular Kendo UI网格导出到Excel
- 如何使用AngularJS将Excel工作表导入到MySql表中
- 导出为Excel的dynamicHTML表
- 表格导出为excel在Chrome 32位版本中使用alasql获取TypeError:get_URL(…).createObjectURL不是函数
- Angularjs数字filter与UI网格无法正常工作
- 如何在使用alasql导出数据时为excel行赋予颜色 – angularjs sql api
- Angular JS ng-CSV
- 使用angularjs在MVC中上传Excel文件。 HttpPostedFileBase是空的
- 如何在Windows机器上处理csv mimetypes