PHP and Excel

hello everyone,

I am doing my first attempt at using PHP with excel.  I need to import all the values from my excel worksheet into MySQL.  Does anyone have any clue how to do so?  I have checked alot of sites from my searches on Google, but i cant figure it out.  

Any info you could give me would be greatly appreciated.

- Dan
LVL 13
flow79Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

m1tk4Commented:
The only way PHP can read Excel files is if it's running on Windows and through ODBC. On Linux you need to save your Excel worksheets as CSV/tab delimited.

If you only need to do it once, you might want to try out this product: http://www.sqlmanager.net/en/products/mysql/dataimport
0
Richard QuadlingSenior Software DeveloperCommented:
I use the very good Zakkis Excel reader class.

There is a good example with the class showing you just how to do what you want.

0
Richard QuadlingSenior Software DeveloperCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
neesterCommented:
I would recommend saving Excel in a CSV format.

PHPMYADMIN will allow direct imports from this!
0
Richard QuadlingSenior Software DeveloperCommented:
I would STRONGLY recommend NOT using CSV files.

They are VERY easy to break.

Think of this.

Your columns are separated by a comma.
Your text columns are surrounded by single or double quotes (pick 1).
Your records are terminated by a CR/LF (one or both, depending upon OS).

Now say you have a description of ...

Black, nylon rope 12'6" long.

Ok.

The , will be ok as it will be within single or double quotes.

Try double

"Black, nylon rope 12'6" long."

Hmmm.

"Black, nylon rope 12'6"

the [space]long. is lost.

Single quotes.

'Black, nylon rope 12'6" long.'

Now we add 6" to the lost part.

CSV is unstructed data.

If you intend to use a plain text file, you need to do 2 thing.

Use a column separator that cannot appear as part of the data.
Use a row separator that cannot appear as part of the data.

In most cases, CSV files have no support for multiple lines of text, when the text contains the same row terminator. On windows, text lines are terminated with CR/LF. If I have multiple lines of text in a cell, then CR/LF will be on each line.


You may not think any of this applies to you. But are you importing people's surnames. I work with a family of O'Connells and we make products 385/80R22.5".

Using a CSV file would fail for us.

In my nearly 20 years of software development, I would say the CSV file has caused more problems with customers data than any virus/worm/hack! At least you know you have to restore all the data after a virus! But when the CSV importer (and there are a LOT of these) says "Hey! Thanks for the data! Yummy!" and it all gets screwed up and you don't know until weeks/months later ... then you REALLY know the feeling of panic/horror!

So. Please do NOT use a CSV file. For your own personal well-being.

Please.

Please, please, please!

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.