[thelist] Reading values from Excel in PHP

Beau Hartshorne beau at members.evolt.org
Tue Jun 18 11:19:00 CDT 2002


> I'm wondering if there is a way for users to upload an Excel
> preset file and have PHP open, read the values, and insert
> the necessary values into the database.
>
> I have looked for quite a while on ways to do this, but all
> I have found is websites teaching people how to fake
> Internet Explorer into thinking the page is an Excel file.

Hi David,

The only thing that I could think of right away was to have the Excel
files exported to tab- or comma-delimited text, then read by php. Once
the user uploaded the text file, you could use PHP's explode function
(http://www.php.net/manual/en/function.explode.php) to help you get the
data into a mySQL database.

I did a quick search on Google Groups and found a thread with a few
alternatives (watch the wrap):

http://groups.google.com/groups?hl=en&lr=&ie=UTF8&oe=UTF8&safe=off&th=f4
b59f48c4914544&rnum=7

Here was the question:

Is it possible to get data from an excel-file and load it in MySQL and
from there use it in a webpage with PHP?

And here was the answer:

Several options:

http://www.php.net/manual/en/ref.com.php
and read the user comments.

http://www.php.net/manual/en/ref.odbc.php
(ditto).

http://www.php.net/manual/en/ref.exec.php
e.g. save as .csv so you can read it using standard php.

Cheers,

Beau





More information about the thelist mailing list