Angularjs: any directive to convert a file XLSX, X

2019-09-21 00:04发布

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;

1条回答
我只想做你的唯一
2楼-- · 2019-09-21 00:46

This can help : https://github.com/brexis/angular-js-xlsx

But it didn't get my number, just letters or letters+numbers.

查看更多
登录 后发表回答