-2

I need to read each line of xlsx and csv file in angularjs and get its data in json format.

Currently I am using angular-file-upload to get that file like this.

$scope.LatLongUploader = new FileUploader({
    //url: "/Map/UploadDamageRatioFile",
    queueLimit: 1,
    removeAfterUpload: true
});

$scope.locationUpload = function () {

        console.log( $scope.LatLongUploader)
        console.log( $scope.LatLongUploader.queue[0].file)
}

and in my html:

      <div ng-show="true" style="margin-top:4px">
      <input style=" width:212px; float:left" type="file" nv-file-select uploader="LatLongUploader" accept=".xlsx" class="AddLocationUpload" />
      <button ng-click="locationUpload()" ng-disabled=""  id="uploadlatlongfile" title="Upload Latitude Longitude File"><i class="fa fa-upload"></i></button></div>

Now I am unable to proceed with this file like object.i found several ways to read this file like this and this.But these are not working.I found some github projects like this_1 and this_1.

I want help in what is best practice to do so?

Should I do this file reading in my server side code and send data to client side?

Which third party app/widget is good for this purpose?

1 Answer 1

-1

Finally I managed to get the file like this...

$scope.getLatLonGFile = function () {
        var FileUpload = document.getElementsByClassName('AddLocationUpload');
        $scope.file = FileUpload[0].files[0];

        for (var i = 0; i < FileUpload.length; i++) {
            FileUpload[i] = function () {
                $scope.file = this.files[0];
            }
        }
    } 

Now you can easily read the file by $scope.file and get data according to the need.

Thanks

Sign up to request clarification or add additional context in comments.

2 Comments

why don't you consider to push data in $scope.file than replacing everytime? // like: $scope.file.push(this.files[0])
but why should i keep those data in scope which i don't need...i think it depends on what scnerio do u have..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.