2

Hy all...I want to import the data from an excel file to a mysql table using php. I google it but I didn't find anything explained so that I could understand the way is made. In present I can import a csv file but I want a xls file. Can you give an example or a starting idea or some tutorial...if not can you tell me: in my csv file I can insert the data only if is separated by commas. Can you tell me if it's possible to insert the data without having to put the commas between the data??

Thanks.

2
  • a csv file by definition uses commas - (C)omma-(S)eparated (V)alues. You can use other characters, like a tab, but most everyone uses commas. You use fgetcsv() to read it in PHP. Commented Jul 12, 2012 at 16:35
  • You can also save an Excel file as a CSV file. Commented Jul 12, 2012 at 16:36

2 Answers 2

2

Here is a basic overview:

  1. Read file in from input stream using a tool like phpexcellreader

  2. Print out the object and see what it looks like

  3. Build your query string based off the fields you want

  4. Make a mysql connection

  5. Insert the string

You could also save the file as a csv, and there are a ton of tutorials on how to work with those.

Sign up to request clarification or add additional context in comments.

Comments

0

you have to convert it into a CSV file, or use a tool to do it directly if you want to do it with code here I leave you 3 different options to do that.

Import Data from Excel in PHP

http://de77.com/php/import-excel-xls-document-into-mysql-database

http://rackerhacker.com/2008/11/07/importing-excel-files-into-mysql-with-php/

I think those tutorials are really good and will help you

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.