I work in excel import function in AngularJS. Now it works fine reading excel values. But I need to read the number of rows of a series of columns here I attached my tested code and the expected result. Here I get the row count as 7, but I need the column name and row of the column to be counted only by the expected row count, since 4 helps solve this problem.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Angular Js XLS</title> <script type="text/javascript" src="http://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="https://unpkg.com/ angular-js-xlsx@0.0.3 /angular-js-xlsx.js"></script> </head> <body ng-app="MyApp"> <div ng-controller="myController"> <js-xls onread="read" onerror="error"></js-xls> </div> </body> <script type="text/javascript"> angular.module('MyApp', ['angular-js-xlsx']) .controller('myController', function($scope) { $scope.read = function (workbook) { debugger; 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>
Data

source share