When I download a spreadsheet from a report, can I include the Report's name in the title of the .csv so I can trace it?

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
Photo of Abigail Crites

Abigail Crites

  • 70 Points
  • frustrated

Posted 8 months ago

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

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
You can use script to download a file or blob of data and force its name. See the attached screenshot where I download all the records in the formula function reference and give it a name myreport.csv:




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

So all you have to do is bind this script to a button and arrange to pass the name you want for the file.
Photo of Forrest Parker

Forrest Parker

  • 628 Points 500 badge 2x thumb
Dan, I was able to implement this solution exactly as you presented it and it works great!  However, I would like to create a CSV in this manner without the column headers.  Is that something that is easily done?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
The variable csv is just a string with newlines separating each row.

This will probably work:
    var csv2 = csv.split('\n').slice(1).join('\n');
    download("myuniquefile.csv", csv2);
Very simple console test:
csv="a,b\n1,2\n3,4"
"a,b
1,2
3,4"
csv.split('\n').slice(1).join('\n');
"1,2
3,4"


Photo of Forrest Parker

Forrest Parker

  • 628 Points 500 badge 2x thumb
Perfect!  That is exactly what I needed.  Thanks!