Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Insert Data from Excel Sheet to MySQL Database using PHP

Hello All,

I'm trying to build a web application which will require me to upload large amounts of data from excel spreadsheets on a repeated basis. I am making my application using PHP and MySQL.

I was wondering if anyone could point me to a tutorial/provide some hints regarding how I will be able to insert spreadsheet data into the MySQL Database using PHP.

Thanks in advance!

2 Answers

Ricky Catron
Ricky Catron
13,023 Points

You could save the exel data as a CSV file thencheck out http://www.homeandlearn.co.uk/php/php10p6.html or google "read CSV file with php" for other solutions.

Thanks for your input!

Ricky Catron
Ricky Catron
13,023 Points

Happy to help! I tried to find out how to do it in python for weeks before i found CSV format!

Robert Komaromi
Robert Komaromi
11,926 Points

This post is a bit old, but since I came here from a Google search I thought I would add an answer. If you need to work with Excel using PHP, you can check out PHPOffice's PHPExcel.

If you are using Laravel, take a look at this Laravel-Excel package - I have used it successfully in a web app I am developing.