I suppose I could just copy paste into excel but i...
# suitescript
k
I suppose I could just copy paste into excel but it'd be handy to have a download button
b
depends on how much work you want to put into it
👍 1
modern browsers can allow you to create a file that you can download
or you can do a post to a suitelet to create and return your file for you
k
Nah, copy paste is easier for a one off like this
Thanks though!
Better solution, just output the database results as a JSON string to a text area field
Except that the string is too long... >.<
c
This has helped me in a similar situation. Just in case it helps you: Field types and their maximum lengths
💯 1
s
there are lots of versions of this same thing on stackoverflow, but i've personally used this model before @Kris Wood
Copy code
const DownloadTable = () => {
    let csvString = CreateCSV(); //read data from page and create csv string
    let fileURL = URL.createObjectURL(
        new Blob([`\uFEFF${csvString}`], {
            type: 'text/csv;charset=utf-8;',
        })
    );
    let downloadLink = document.createElement('a');
    let fileName = `Name your file here`;

    downloadLink.setAttribute('href', fileURL);
    downloadLink.setAttribute('id', 'download');
    downloadLink.setAttribute('download', fileName);
    document.body.appendChild(downloadLink);

    downloadLink.click();
    URL.revokeObjectURL(fileURL);
}