Last active
January 27, 2020 10:55
-
-
Save AbrarJahin/22e7fdcbe1beb3827e7aee1f9d0af72f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Angular Js XLS</title> | |
| <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> | |
| <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.9.13/xlsx.full.min.js"></script> | |
| <script type="text/javascript" src="//unpkg.com/angular-js-xlsx/angular-js-xlsx.js"></script> | |
| </head> | |
| <body ng-app="MyApp"> | |
| <div ng-controller="myController"> | |
| <js-xls onread="read" onerror="error"></js-xls> | |
| <!-- <input type="file" ng-change="read" onerror="error"> --> | |
| </div> | |
| </body> | |
| <script type="text/javascript"> | |
| angular.module('MyApp', ['angular-js-xlsx']) | |
| .controller('myController', function($scope) { | |
| $scope.read = function (workbook) { | |
| var headerNames = XLSX.utils.sheet_to_json( workbook.Sheets[workbook.SheetNames[0]], { header: 1 })[0]; | |
| var data = XLSX.utils.sheet_to_json( workbook.Sheets[workbook.SheetNames[0]]); | |
| console.log(headerNames); | |
| console.log(data); | |
| for (var row in data) | |
| { | |
| Object.keys(data[row]).forEach(function(key) { | |
| console.log("Key = >" + key); | |
| console.log("Value => " + data[row][key]); | |
| console.log("==========================="); | |
| }); | |
| } | |
| } | |
| $scope.error = function (e) { | |
| console.log(e); | |
| } | |
| }); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in to file js create one variable bool (listData = false) and data binding in html file ng-if="listData"
and success data show in html template