Aggrid Export to Excel API

Hello, I would like to add a button in my Streamlit project to Export to Excel an Aggrid Table.
Is there a way of doing it ? I tried various things (api.exportDataAsExcel()
) but could not make it). Thank you for your help.
Here is what I have tried :

js_code = JsCode(“”"
function(e) {
const api = e.api;
window.addEventListener(‘ExportXls’, () => {

if st.button(‘Export’):
export_js = ‘’’

st.markdown(export_js, unsafe_allow_html=True)