0

I am getting a json response, Now I want to convert it to a .CSV file for MSExcel using JavaScript and show users to download or Open it in a dialog box. Please help me out how to do it. Thanks in advance

skywalker
  • 826
  • 1
  • 10
  • 18
Tushar
  • 151
  • 2
  • 18
  • 1
    For starters, show us your JSON structure. What have you tried so far? – Alex R. Mar 14 '14 at 09:52
  • Why is this tagged `java`? – fge Mar 14 '14 at 09:53
  • Use Google search a bit more, and then when you have some code come back here. – skywalker Mar 14 '14 at 09:54
  • I am getting a Json response like {"info":{"totalResultCount":628,"resultIndex":1,"resultCount":20},"resultArray":[{"refId":789,"refType":"Location","refValue":"Ornskoldsvik","enabled":"Y"},{"refId":790,"refType":"Location","refValue":"Drayton","enabled":"Y"},{"refId":791,"refType":"Location","refValue":"Namakwa Sands","enabled":"Y"}]} – Tushar Mar 20 '14 at 07:02
  • So I have to convert this into CSV and show to the user that he wants to open it download it or cancel it. I am not getting anything how to do it and make compatible to all browsers. – Tushar Mar 20 '14 at 07:04

1 Answers1

0

Converting from JSON to CSV must be done by hand using JavaScript as the mapping depends on the JSON content.

Once you have built a CSV string you can do something like this:

Export to csv in jQuery

Community
  • 1
  • 1
Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
  • But does this work for IE9 and above, I am not finding any solution for how to show Download, Open or cancel for it. – Tushar Mar 20 '14 at 07:42