0

After downloading into csv, i am getting this result, where the display setting is displaying [object Object]

enter image description here

How it should look like

enter image description here

My JS :

  $scope.download = function () {
  var csv = jsonToCsv(['ThemeName', 'DataSharing', 
 'DisplaySetting', 'ExpiryDate', 'Icon', 
 'PusblishDate','QueryName','ThemeName', 'ThemeOwner'], health)
  var csvBlob = new Blob([csv], { type: 'text/csv' });
  saveAs(csvBlob, 'json.csv');
  };

May i ask how to modify the code so that it would show? And also is it possible to choose what object I want to display in the csv file? I would really really appreciate any help! I don't mind changing to another way of coding as long as it has the solution. So, if you have any link which I can refer to would be really nice too. Thanks!

Stringify

   else if ($scope.all[i].CATEGORY == 'Health')
  {
     health.DISPLAY_SETTING = 
     JSON.stringify(health.DISPLAY_SETTING)
     health.push($scope.all[i]);
  }

1 Answer 1

1

Try stringifying the DisplaySetting property inside health before converting it to csv:

health.DisplaySetting = JSON.stringify(health.DisplaySetting);
Sign up to request clarification or add additional context in comments.

1 Comment

I updated my code above, is that how you do it? Cause it's not working for me

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.