Can you add an 'Export' Button in App?

verytiredgirl
verytiredgirl Member
edited November 26 in Charting

I have a Pivot Table Card that the end users would like to export to excel or pdf. In order to do that they would need to Expand the Card → Card Options → Export → Export Options.

Is there any way that I can add a Button 'Export' in App and take the users to Export Options if they click on it?

Tagged:

Best Answer

  • ArborRose
    ArborRose Coach
    Answer ✓

    I don't think there is a direct way to programmatically add a custom button inside a pivot card to trigger an export. But you can probably do something similar through a custom card or app.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Answers

  • ArborRose
    ArborRose Coach
    Answer ✓

    I don't think there is a direct way to programmatically add a custom button inside a pivot card to trigger an export. But you can probably do something similar through a custom card or app.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • It's funny, on an embedded app, you can "allow export" which surfaces the Export button to be right next to the "expand for detailed view" button, which is way easier to find for users. It would be nice if this was possible in an AppStudio app that was shared directly in Domo.

    Please 💡/💖/👍/😊 this post if you read it and found it helpful.

    Please accept the answer if it solved your problem.

  • art_in_sky
    art_in_sky Contributor

    @ArborRose How would I be able to achieve it through custom card/ App?

  • @art_in_sky - I haven't done this for anything myself. I'd have to work through it. I would probably try to leverage the Domo Embed API. Embed the card in an iframe and add an export button to append ?export=true.


    domo.get(`/v1/cards/{CARD_ID}`)
    .then((card) => {
    const iframe = document.createElement('iframe');
    iframe.src = card.embedUrl;
    iframe.width = '100%';
    iframe.height = '600px';
    document.getElementById('pivotCardContainer').appendChild(iframe);
    document.getElementById('exportButton').addEventListener('click', () => {
    window.open(`${card.embedUrl}?export=true`);
    });
    })
    .catch((error) => {
    console.error('Error embedding card:', error);
    });

    Or try to access the dataset using Domo's API.

    document.getElementById('exportButton').addEventListener('click', async () => {
    const datasetId = 'YOUR_DATASET_ID';
    const response = await domo.get(`/v1/datasets/${datasetId}/data`);
    const data = response.data;

    // Use SheetJS or other tools to generate a file
    const workbook = XLSX.utils.book_new();
    const worksheet = XLSX.utils.json_to_sheet(data);
    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
    XLSX.writeFile(workbook, 'export.xlsx');
    });

    But a quick search on the web pulls some other conversations where it looks like maybe someone has already suggested a way.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **