Script for Export of Tables

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
As I need to periodically export data from all or nominated tables to a CSV file,  other than doing it one by one in each table,  is there a script that could achieve this?   
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
Just adopt the code in this example:

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=355

Calling the function download(filename, content) will immediately save the content to the given filename. You have complete control over the filename and the content.


Isn't JavaScript fun?
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb
Thanks a lot.  Is this function saved as a page and what extension is used by the extension?  Is this going to download separate files for each table or could this be an Excel file with various tabs?  Does it export all tables?  

So in this case, I will be adopting following two lines in terms of file name and my app site?

  a.download = filename;
var promise = $.get("https://SUBDOMAIN.quickbase.com/db/DBID?a=q&qid=QID")
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
You would use that code within a user defined page which would have other code in it from your overall implementation. One call of download() downloads one file. Call it multiple times if you want to download multiple downloads. Or use JSZip to create a zip file composed of all the individual files. See:

https://stuk.github.io/jszip/

FWIW, Microsoft Office files is just a zipped collection of XML files.

I would love to answer more JavaScript questions but I am off to my JavaScript Meetup and a night of heavy drinking:

Southeast Michigan JavaScript Meetup
https://www.meetup.com/SEM-JS/
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb
Thanks.  You can answer this later, no rush. How do you call the function?
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb
Hi Dan, could you kindly look into this?
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb
Dan, I must compliment for the fabulous solution you have provided.  Thanks a lot.