810

I know there are lot of questions of this nature but I need to do this using JavaScript. I am using Dojo 1.8 and have all the attribute info in array, which looks like this:

[["name1", "city_name1", ...]["name2", "city_name2", ...]]

Any idea how I can export this to CSV on the client side?

1
  • Important PSA to all developers: When making a download link, please take time to consider the most appropriate filename format. It is all too common to see ProductsExport.csv or 65457a9d-167d-4954-8894-56fd13d3b4ee.csv instead of something like Products_2024-10-30.csv Commented Dec 30, 2024 at 21:34

31 Answers 31

1
2
-1

Here is very good video on how to do it: https://www.youtube.com/watch?v=JPxzeG4N5nQ

its 13 min and this guy is 'stright to the point'... i.e. NOT a typical youtuber

Fundamentally you want CSV in the following format: heading1, heading2, heading3 \n value1, value2, value3 \n value1a, value2a, value3a \n etc.

so the whole tutorial is about achieving this.

then for download you just create a Fake Anchor tag that you auto click on, and then delete the anchor tag.

just watch the tutorial, its all there.

1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.