Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Exporting Grid Data (CSV/Excel)

Exporting Grid Data (CSV/Excel)

~6 Min. Lesezeit Zuletzt aktualisiert am August 9, 2026

Unlike many other features in this tutorial, a CSV/Excel export button is almost entirely declarative - the generic Magento core controller handles the actual export logic.

exportButton in listing.xml

<listingToolbar name="listing_top">
    <exportButton name="export_button"/>
    <filters name="listing_filters"/>
    <massaction name="listing_massaction"/>
    <paging name="listing_paging"/>
</listingToolbar>

That's it - Magento automatically renders two options ("Export CSV" and "Export Excel XML") and calls already-existing core controllers (Magento\Ui\Controller\Adminhtml\Export\GridToCsv and GridToXml) for them. A custom export controller isn't needed for the standard case.

Which columns get exported

Export uses exactly the same column configuration as the visible grid - including the Rating column from chapter 19, whose star string then also ends up in the CSV. For a numeric export value (instead of the stars), a column can be hidden from the grid with <visible>false</visible> but still exported, by supplying the underlying raw value through a second, invisible column.

<column name="rating_raw">
    <settings>
        <visible>false</visible>
        <label translate="true">Rating (numeric)</label>
    </settings>
</column>

Achtung: visible: false hides a column in the grid but does not automatically remove it from the export - grid visibility and export participation are two separate settings (visible vs. exportable). Anyone hiding a sensitive column (for example internal notes) from the grid must also explicitly exclude it from export with <exportable>false</exportable>.

Permission for export

The export controller checks the same ACL resource as the parent grid - without read access to Mironsoft_Testimonial::testimonial, the export button doesn't even show up for the affected role (chapter 25 goes deeper into the ACL structure).

Tipp: For large grids, it's worth checking the server-side row limit: export runs by default over the entire, unfiltered dataset (not just the current page), which can lead to long load times for very large tables - chapter 24 addresses exactly this performance topic.