Transform your excel data into a relational database: Symfony

Let’s break the ice :


  • phpMyAdmin
  • Symfony: v4.12.10
  • PHP: v7.2.19

To start with :

  1. Install the phpSpreadSheet in your Symfony project:
composer require phpoffice/phpspreadsheet
use PhpOffice\PhpSpreadsheet\IOFactory;
* @Route("/upload-excel", name="xlsx")
example of an excel file containing a list of users
  • Now, Let’s observe the result in Postman:
  • Continuing with code; we will upload the data in our DB:
  • Now if we check our User Table we’ll find the data imported from the excel file.

Bonus Step:

  • Check that the person connected and making the request has a “ROLE_ADMIN”



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store