# Ag-grid exports

**URL:** <https://community.plotly.com/t/ag-grid-exports/72395>\
**Category:** Dash Python\
**Created:** [February 7, 2023, 3:51pm UTC](https://community.plotly.com/t/ag-grid-exports/72395 "2023-02-07T15:51:36Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![davzup89](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@davzup89](https://community.plotly.com/u/davzup89)\
**Post date:** [February 7, 2023, 3:51pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/1 "2023-02-07T15:51:36Z")

</div>

Can we import/enable any of ag-grid export capabilities in its Dash counterpart? For example: [JavaScript Data Grid: Excel Export](https://www.ag-grid.com/javascript-data-grid/excel-export/)

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [February 7, 2023, 3:54pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/2 "2023-02-07T15:54:27Z")

</div>

Hello @davzup89,

Currently, excel export from AG grid is only available for it’s enterprise customers.

Right now, there isnt access for the excel specific export, but the export of CSV is available.

You can, however, export the dataframe to excel via normal means, but this will not include things like formatting, etc.

---

<div class="post-metadata">

**Author:** ![davzup89](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@davzup89](https://community.plotly.com/u/davzup89)\
**Post date:** [February 7, 2023, 4:10pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/3 "2023-02-07T16:10:27Z")

</div>

The export of CSV is meant by means of dataframe export or as dash ag-grid function? How can we enable it?

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [February 7, 2023, 4:16pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/4 "2023-02-07T16:16:16Z")

</div>

It is available currently from dash-ag-grid.

You’ll have to create a button and on click, pass True to `enableExportDataAsCsv` currently.

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [February 7, 2023, 8:36pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/5 "2023-02-07T20:36:44Z")

</div>

You can find an example in the docs here:

> **[Dash AG Grid Import Export](https://dashaggrid.pythonanywhere.com/import-export/export-data-as-csv)**
>
> Dash AG Grid documentation -- Alpha release

---

<div class="post-metadata">

**Author:** ![mich2210](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mich2210](https://community.plotly.com/u/mich2210)\
**Post date:** [March 1, 2023, 10:33am UTC](https://community.plotly.com/t/ag-grid-exports/72395/6 "2023-03-01T10:33:41Z")

</div>

I was wondering if it was possible to implement clipboard function to Dash AG Grid.

Such as native JS Ag-grid enables by default: [JavaScript Data Grid: Clipboard](https://www.ag-grid.com/javascript-data-grid/clipboard/)

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [March 1, 2023, 12:33pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/7 "2023-03-01T12:33:39Z")

</div>

Hello @mich2210,

That is an enterprise only feature, as denoted by the red e up at the top of the topic.

To turn it on, you need to enableEnterpriseFeatures

---

<div class="post-metadata">

**Author:** ![mich2210](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mich2210](https://community.plotly.com/u/mich2210)\
**Post date:** [March 1, 2023, 12:45pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/8 "2023-03-01T12:45:39Z")

</div>

Thanks @jinnyzor! Totally missed that.

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [March 1, 2023, 4:31pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/9 "2023-03-01T16:31:48Z")

</div>

@mich2210  
Clipboard is (surprisingly) an enterprise feature, but it is possible to do some simple clipboard operations with `dcc.Clipboard` Here is an example

```auto

import pandas as pd

import dash_ag_grid as dag
from dash import Dash, html, dcc, Input, Output, State
import plotly.express as px

df = px.data.gapminder()

app = Dash( __name__ )

columnDefs = [
    {"headerName": "Country", "field": "country", "checkboxSelection": True, "headerCheckboxSelection": True},
    {"headerName": "Continent", "field": "continent"},
    {"headerName": "Year", "field": "year"},
    {"headerName": "Life Expectancy", "field": "lifeExp"},
    {"headerName": "Population", "field": "pop"},
    {"headerName": "GDP per Capita", "field": "gdpPercap"},
]

app.layout = html.Div(
    [
        dcc.Markdown("This grid has multi-select rows with checkboxes."),
        html.Button([html.Span("copy selected"), dcc.Clipboard(id="clipboard")]),
        dag.AgGrid(
            id="clipboard-grid",
            columnDefs=columnDefs,
            rowData=df.to_dict("records"),
            columnSize="sizeToFit",
            defaultColDef={"resizable": True, "sortable": True, "filter": True},
            rowSelection="multiple",
        ),
        dcc.Textarea(placeholder="paste area", id="clipboard-output", style={"width": "100%", "height":200}),
    ],
    style={"margin": 20},
)

@app.callback(
    Output("clipboard", "content"),
    Input("clipboard", "n_clicks"),
    State("clipboard-grid", "selectedRows"),
)
def selected(n, selected):
    if selected is None:
        return "No selections"
    dff = pd.DataFrame(selected)
    dff = dff[["country", "continent", "year", "lifeExp", "pop", "gdpPercap"]]
    return dff.to_string()

if __name__ == " __main__":
    app.run_server(debug=True)

```

![aggrid_clipboard](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/8/1/81edd1b26039820ac9252ba9089f73e95baf0d75.gif)

---

<div class="post-metadata">

**Author:** ![kbally](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kbally](https://community.plotly.com/u/kbally)\
**Post date:** [March 14, 2023, 6:31pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/10 "2023-03-14T18:31:38Z")

</div>

This worked great but exports the entire grid regardless of visibility (i.e hidden or not). How can I go about only exporting the visible columns?

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [March 14, 2023, 6:33pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/11 "2023-03-14T18:33:50Z")

</div>

@kbally,

Did you try adjusting the params here?

> **[React Data Grid: CSV Export](https://www.ag-grid.com/react-data-grid/csv-export/#csvexportparams)**
>
> The grid data can be exported to CSV with an API call, or using the right-click context menu (Enterprise only) on the Grid. Download v29 of the best React Data Grid in the world now.

---

<div class="post-metadata">

**Author:** ![kbally](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kbally](https://community.plotly.com/u/kbally)\
**Post date:** [March 14, 2023, 7:22pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/13 "2023-03-14T19:22:05Z")

</div>

Yes I did. I also tried using columnState as an input in a callback to set the hidden cols but columnState returns null each time

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [March 14, 2023, 7:43pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/14 "2023-03-14T19:43:08Z")

</div>

Hi @kbally

See example #2 in the docs to see how to use columnState in a callback with the Clipboard

> **[Dash AG Grid Import Export - clipboard](https://dashaggrid.pythonanywhere.com/import-export/clipboard)**
>
> Dash AG Grid documentation -- Alpha release

---

<div class="post-metadata">

**Author:** ![kbally](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kbally](https://community.plotly.com/u/kbally)\
**Post date:** [March 14, 2023, 7:47pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/15 "2023-03-14T19:47:36Z")

</div>

I have tried that as well as the example below but i’m still getting Null. I am using Dash Enterprise V1.3.0 so maybe that’s the issue?

> **[Dash AG Grid Column Definitions](https://dashaggrid.pythonanywhere.com/columns/column-state)**
>
> Dash AG Grid documentation -- Alpha release

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [March 14, 2023, 7:49pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/16 "2023-03-14T19:49:12Z")

</div>

Dash Enterprise shouldnt be a factor, what version of Dash AG Grid are you running?

---

<div class="post-metadata">

**Author:** ![kbally](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kbally](https://community.plotly.com/u/kbally)\
**Post date:** [March 14, 2023, 7:55pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/17 "2023-03-14T19:55:23Z")

</div>

dash\_ag\_grid - 1.3.0

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [March 14, 2023, 7:57pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/18 "2023-03-14T19:57:49Z")

</div>

Yeah, you’ll need to install the current versions of the open source.

`pip install dash-ag-grid==2.0.0a3`

---

<div class="post-metadata">

**Author:** ![kbally](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kbally](https://community.plotly.com/u/kbally)\
**Post date:** [March 14, 2023, 8:16pm UTC](https://community.plotly.com/t/ag-grid-exports/72395/19 "2023-03-14T20:16:42Z")

</div>

Yup that fixed it. Much appreciated 🙂
