-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?

Amrit
  • 2,115
  • 1
  • 21
  • 41

1 Answers1

-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

Amrit
  • 2,115
  • 1
  • 21
  • 41
  • why don't you consider to push data in $scope.file than replacing everytime? // like: $scope.file.push(this.files[0]) – Sheelpriy Apr 03 '18 at 10:36
  • but why should i keep those data in scope which i don't need...i think it depends on what scnerio do u have.. – Amrit Apr 03 '18 at 10:50