I'm working on a project where I need to import Excel data to my Symfony database. But the problem is that I don't know how to do that. I tried with ExcelBundle. The project is: User has to use a form button to send his Excel file and I need to extract the data without headers to fill my Database. Can you help me ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If you can get your excel spreadsheet into CSV format, there is a really good package that can deal with it!
Have a look at this: http://csv.thephpleague.com/9.0/
Here's their example showing how easy it is to get your table into the DB
Give it a try!
As mentioned in a comment you can use PHPExcel. Install the library using composer
A typical reader might look something like
Call the reader class from your controller
That should get you started. And yes you could convert to csv but why bother. Just as easy to read the raw file and save your users an extra step.
You can use fgetcsv PHP function, an exemple here.
Beford the Excel file must be changed to a CSV file.