Hi Nada,
You can use the Excel Exporter Module to export the data.
You can create a template with your form attributes along with your associated attributes
or
We can create a custom Java action which helps us to generate Excel files
Refer to below documentations for Excel generation with Static and Dynamic columns
https://www.indiumsoftware.com/blog/guide-creating-high-performance-excel-generation/
https://www.indiumsoftware.com/blog/high-performance-excel-generation-dynamic-entity-and-columns/