Skip to main content
Question

Download Excel CSV file directly to the local system on the click of a button on the Table Report

  • December 6, 2018
  • 0 replies
  • 334 views

I want an Action button on the current page table report where clicking on that button will directly downloads the Excel CSV File to my Local System. Is it possible to have a button like that in QuickBase and if So, How to achieve this in QuickBase ?

(Note: I don't want to use QuickBase IMPORT/EXPORT option to download the file)
This topic has been closed for replies.

  • Registered
  • December 6, 2018
Yes it is possible in a variety of ways. Here is one way that uses a technique to jam the relevant JavaScript into an onclick handler of an <a> element synthesized using a Rich Text Formula Field.
"<a href=# class='Vibrant Success' onclick='
function download(filename, content) {
  var blob = new Blob([content]);
  var a = document.createElement('a');
  a.href = window.URL.createObjectURL(blob); 
  a.download = filename;
  a.style.display = 'none';
  document.body.appendChild(a);
  a.click();
}

var dbidTable= 'bgcwm2m4g';
var qid = '1';
var output = 'output.csv';
var url = '${dbidTable}?a=q&qid=${qid}&opts=csv';
$.get(url, function(csv) {
  download('${output}', csv);
});
'>Download</a>"

Here is a screenshot of the Formula Definition  being entered:



This is one big text string with hard-coded values for dbidTable, qid and output. You would need to changes these values to suit your needs or modify the formula to pass in field values from the record.

There are three types of quotes used in this formula and you need to take great care not to mess any of them up:

(1) Double quotes (ie ") are used at the beginning and end a double quotes are used in the formula language to delineate text strings.

(2) Single quotes (ie ') are used to deliniate the start and end of the onclick attribute of the <a> element.

(3) Backtick quotes (ie ') are used in the body of the JavaScript code where normally you might use single or double quotes and also where string interpolation is being performed (their real use).

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=700

I just noticed that this is the 700th record entered into the Pastie Database so I am going to celebrate with Kool & The Gang!



  • Registered
  • December 6, 2018
QuickBase refuses to make it easy to introduce JavaScript into the product so we will just take over the formula language with script.

I came up with a snappy name that will make this technique memorable. Henceforth this technique will be called:
Three Quotes And A Script Technique = 3Q&S

Forum|alt.badge.img+17
  • Community Moderator
  • December 6, 2018
Hi Murali, 

Currently a report can be saved as a CSV by using the option to Import/Export or 'Save as Spreadsheet' under the More dropdown on a table report. 'Save as Spreadsheet' will jump right to creating a CSV to download. Either will allow a user to pull the data from a Quick Base table into a CSV. Out of curiosity is there something about the two options under the More dropdown that make them undesirable for your use?_