How to export

First off, for those of you who don't know you can export your adminlist as a csv file, this is how you can do it:

Open your adminlist configurator (src/YourVendor/YourWebsiteBundle/AdminList/YourAdminListConfigurator.php) and add the following method:

public function canExport()
{
        return true;
}

Now refresh your adminlist in the browser and you'll notice the export button on the right.

 

When you have an existing adminlist that you already configured for exporting, you'll need to add some extra configuration to make the Excel export functionality work. Open up your admin list controller and look for the "exportAction" method, which should look like the following :

 

/**
 * The export action
 *
 * @param string $_format
 *
 * @Route("/export.{_format}", requirements={"_format" = "csv"}, name="kumaawesomebundle_admin_car_export")
 * @Method({"GET", "POST"})
 * @return array
 */
public function exportAction($_format)
{
    return parent::doExportAction($this->getAdminListConfigurator(), $_format);
}

As you can see, the _format variable is configured to be "csv" only. To be able to export your adminlist as an Excel sheet, you'll need to change the "csv" into "csv|xlsx".

/**
..
* @Route("/export.{_format}", requirements={"_format" = "csv|xlsx"}, name="kumaawesomebundle_admin_car_export")
..
*/

And that's it! You should now be able to export your adminlist as an Excel sheet.

Questions?

Feel free to contact the author