Home » Php » Laravel excel – Split Excel file into mulitple files (import/export file)

Laravel excel – Split Excel file into mulitple files (import/export file)

Posted by: admin October 26, 2017 Leave a comment

Questions:

Currently i am working on my project and i am using laravel excel from Maatwebsite. I have a situation and i need advice how i can solve this the most efficient way. I have a option in my mind which i will explain in a second.

What i want to accomplish is the following:
I have a Excel file with mixed data (see picture for example). I want to seperate the data into new Excel template files based on a unique combination of cells.

Unique combination: length, width, Thickness.

enter image description here
Every unique combination has his own excel template.

If the combination is 151.25, 120,15, 0.54 the rows with this combination will go in file 1.
If the combination is 130.75, 120.30, 0.70 the rows with this combination will go in file 2.

When everything is sepertated you download the files. Basiclly you are seperating one file into multiple files. I created a diagram to illustrate it and make it more clear.

enter image description here

My first thought was to import all the data into the database. Than grab the data from the database and check if the combiation matches with a statement. If that is the case, the data will go to a pre defined excel sheet.

151.25, 120,15, 0.54 -> excel template 1

130.75, 120.30, 0.70 -> excel template 2


Right now the user can upload his exel file. I read the excel fileand store it in the database. What the next step i need your help for suggestions and maybe examples. I am new to the laravel excel part. I hope people understand it and have some suggestions they want to share. 🙂

Answers: