I would like to know the best way to import a Excel file in my HTML, with Angular and read it data. Any ideias?
I did this but from .CSV to array object, it worked perfect with a angular directive. Is there anything to Excel files?
This is the directive:
// CSV -> Angularjs Object
MyApp.directive('fileReader', function () {
return {
scope: {
fileReader: "="
},
link: function (scope, element) {
$(element).on('change', function (changeEvent) {
var files = changeEvent.target.files;
if (files.length) {
var r = new FileReader();
r.onload = function (e) {
var contents = e.target.result;
scope.$apply(function () {
scope.fileReader = contents;
});
};
r.readAsText(files[0]);
}
});
}
};
});
HTML:
<input type="file" file-reader="fileContent" />
ANGULAR:
$scope.fileContent;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…