A portrait of Duncan McClean
01 Apr, 2022 2 min read

CSV Exporter for Statamic

We’ve just launched our first add-on for Statamic, a delightful content management system built on Laravel. It’s the CSV Exporter add-on. Yesterday, we had a client who needed to be able to export certain pieces of content on-demand in a CSV format.
CSV Exporter for Statamic

We’ve just launched our first add-on for Statamic, a delightful content management system built on Laravel. It’s the CSV Exporter add-on.

Yesterday, we had a client who needed to be able to export certain pieces of content on-demand in a CSV format. We decided to build out a public add-on to do the job!

All a content editor needs to do is select the collections they wish to export, click the big blue ‘Export’ button and within a few seconds, they’ll get a download of a ZIP folder that contains a CSV file for each of the collections selected.

Screenshot

The add-on is open-source and available on the Statamic Marketplace for anyone to pull in and use on their site.

How it works

In case you’re interested in knowing how it works behind the scenes:

  • We’ve created what’s known as a ‘Utility’ in Statamic. Essentially, it gives us a route, a view & adds some Nav items under the Utilities page in the Control Panel.

  • Whenever a user hits the export button, it submits to our controller, which will start the export process.

  • We’re pulling in Laravel Excel (an open-source package) so we can easily generate the CSVs. We loop through each of the fields from the entry’s blueprint, grab the raw value from the entry, and then give that to Laravel Excel for it to output.

  • In order to allow for exporting multiple collections at once, the CSVs are generated, then grouped together in a ZIP file which will be downloaded to the user’s computer.

Give our Statamic developers a shout to learn more.