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

  • 0
  • 1
  • Question
  • Updated 3 days ago
  • In Progress
  • (Edited)

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)
Photo of Murali Krishna Gangineni

Posted 4 days ago

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

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
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 dbidTableqid 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!


(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
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
(Edited)
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,214 Points 5k badge 2x thumb
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?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
He wants a friction-less single button way to download and doesn't want to navigate through the GUI.

My technique is very general but you can make it even simpler by just adding &opts=csv to the end of the report URL. This example will immediately download the CSV for the Formula Function report

Download Formula Functions Report as CSV:
https://login.quickbase.com/db/6ewwzuuj?a=q&qid=6&opts=csv

QuickBase immediately downloads the report as CSV because of the way the content-disposition header is set in the response. What you don't get with this simpler approach is (1) the ability to name the CSV file or (2) potentially modify the CSV in some fashion prior to download.

The technique I have supplied is extremely general. You can download your QuickBase data in any text format you want with the download(filename, content) function with a single button click.


(Edited)
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,214 Points 5k badge 2x thumb
Thanks Dan, that is what I am curious of. I just wanted to confirm if it is the location of the option or if it is something about how the options in the dropdown work so I can pass that feedback along. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
This is the feedback you should pass along:

QuickBase staff is collectively obsessed with use case analysis and hard-coding features that have limited ability to be further customized by the end user. Users want general capabilities that can be customize to their individual snowflake needs no matter how cosmetic or complex.

But user's individual requests often go unaddressed because the feature is viewed as non-critical and never crosses the popularity threshold so that marketing and product managers commit to developing the feature. It is all about the long tail today.

Every GUI ease of use feature you develop should have an analog that can accomplish the same thing through an API and script automation. You need functional parity between the "clicks not code" and "code not clicks" memes. Without greater support for APIs and script you are locking your users out of the using the cornucopia of features that are coming through browser innovations. QuickBase should view all the innovations that are jammed into browsers today as economic externalizes that someone else paid for developing.

(Edited)
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,214 Points 5k badge 2x thumb
Thank you for your feedback Dan I'll make sure to pass it along as I have in the past. I'm curious have you ever written up a User Voice post on your suggestions for expanded APIs and scripting support? I searched for one and didn't see it.

I've seen your posts on it on other questions and passed them along but having a central written out suggestion (or set of suggestions) would help with passing along the feedback outside of the specific questions in the thread. I would also be curious to see the votes it would get given the community members who make use of your techniques and ask about them to pass along to product development as well since the activity is spread across the questions.
(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
I rarely use UserVoice or your support service. Quite frankly I have minimal contact with QuickBase staff (except when I misbehave!). I do security work so it is essential that I can understand all aspects of web applications and technologies without any inside knowledge.

Feel free to summarize my views and reports internally.

Also, if someone wants to make me an Agile Coach for the Day I will be happy to fly out to Boston at your expense and tell your crew everything you should do to improve the product. I would be an excellent Agile Coach for the Day and could offer great advice such as "what were you thinking?" or "why the heck did you do that?"