It may be a better idea to use the export excel module, which allows you to customize your export (and put your button anywhere you want).
https://docs.mendix.com/howto/integration/using-the-excel-exporter/
But I am sure you can also do it using css and javascript (not sure with only css)
Using javascript I would do the following :
Put a container that contain your datagrid, put it to display none or visibility hidden.
Then use javascript (html snippet, or nanoflow), to take the export button (use a specific class inside that button to retrieve it easily) and move it wherever you want, using appendChild().
Hope this helps