# Exporting a file

**URL:** <https://community.hubspot.com/t/exporting-a-file/108935>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [June 7, 2024, 5:36pm UTC](https://community.hubspot.com/t/exporting-a-file/108935 "2024-06-07T17:36:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebp](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ebp/32/104913_2.png) [@ebp](https://community.hubspot.com/u/ebp)\
**Post date:** [June 7, 2024, 5:36pm UTC](https://community.hubspot.com/t/exporting-a-file/108935/1 "2024-06-07T17:36:00Z")

</div>

Hi,

I’m creating a custom card with data from outside Hubspot.

I want to export in CSV format the content of the table I created with those datas.

So, is there a way to add a button on the card to download a CSV string (type: ‘text/csv’) ?

Thanx

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [June 13, 2024, 11:59pm UTC](https://community.hubspot.com/t/exporting-a-file/108935/2 "2024-06-13T23:59:49Z")

</div>

Hey, @ebp 👋 Did you make any progress on this project? If not, we can try tagging in a few of our community experts who have CRM custom card building experience.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![ebp](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ebp/32/104913_2.png) [@ebp](https://community.hubspot.com/u/ebp)\
**Post date:** [June 14, 2024, 5:42am UTC](https://community.hubspot.com/t/exporting-a-file/108935/3 "2024-06-14T05:42:13Z")

</div>

Hi Jaycee,

Thanx for your answer.

I didn’t progress any more.

I found a workaround outside the card (my export is sent by email in the API).

It’s not what i really want but it does the job.

---

<div class="post-metadata">

**Author:** ![aanchalshethHS](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@aanchalshethHS](https://community.hubspot.com/u/aanchalshethHS)\
**Post date:** [June 18, 2024, 1:40pm UTC](https://community.hubspot.com/t/exporting-a-file/108935/4 "2024-06-18T13:40:03Z")

</div>

Hi @ebp ,

Confirming that you’re using a [UI Extension custom card.](https://developers.hubspot.com/beta-docs/guides/crm/ui-extensions/overview) Is that correct?

---

<div class="post-metadata">

**Author:** ![aanchalshethHS](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@aanchalshethHS](https://community.hubspot.com/u/aanchalshethHS)\
**Post date:** [June 21, 2024, 2:19pm UTC](https://community.hubspot.com/t/exporting-a-file/108935/5 "2024-06-21T14:19:59Z")

</div>

Hi @ebp ,

One way of doing this is by generating a data URL and then embedding the URL in the Link component. i can give an example, but make sure you perform necessary security & scalability validations on your end before using in Prod.

Code example:

```lia-code-sample
const dataArray = [
 { id: 1, name: 'Alice', age: 25, department: 'HR' },
 { id: 2, name: 'Bob', age: 30, department: 'Engineering' },
 { id: 3, name: 'Charlie', age: 28, department: 'Marketing' },
 { id: 4, name: 'David', age: 35, department: 'Sales' },
 ];

 const getDataUrl = (dataArray) => {
 const csvRows = [];
 const headers = Object.keys(dataArray[0]);
 csvRows.push(headers.join(','));

 for (const row of dataArray) {
 const values = headers.map(header => {
 const escaped = ('' + row[header]).replace(/"/g, '\\"');
 return `"${escaped}"`;
 });
 csvRows.push(values.join(','));
 }

 const csvData = csvRows.join('\n');
 const dataUrl = 'data&colon;text/csv;charset=utf-8,' + encodeURIComponent(csvData);

 return dataUrl;
 };

 const dataUrl = getDataUrl(dataArray);

```

And in the Link component:

`<Link href={dataUrl}>Download</Link>;`

Does that help?

---

<div class="post-metadata">

**Author:** ![ebp](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ebp/32/104913_2.png) [@ebp](https://community.hubspot.com/u/ebp)\
**Post date:** [June 27, 2024, 2:13pm UTC](https://community.hubspot.com/t/exporting-a-file/108935/6 "2024-06-27T14:13:08Z")

</div>

Thank you !

It does the job !
