Read Excel with php

Is there a class or a function that facilitates reading excel directly into php?

Specifically, I have a two tab sheet. Ideally, the customer would upload the Excel file into a specific location on the web server (using a custom php program), then php would read the Excel tabs & store the data into a MySQL database.

Many times in the past I have done this by first having the customer save the Excel tabs (sheets) individually as csv or tab delimited files; I am well aware of how to accomplish that, just thinking it would be easier on them to avoid those steps.

Thanks
Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
I tried phpExcelReader. Sample does bot work with the example excel file they provide.

Not a good start.
Loganathan NatarajanLAMP DeveloperCommented:
What is the error you got? Please provide more details for not work?
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
Loganathan Natarajan,

When you download from Source Forge, they give you an example.php file (attached). Also, they give you a supposed Excel file ( jxlrwtest.xls). I cannot open that Excel file in Excel, it gives the error message attached.

I uploaded the files to my web server; I ran example.php, blank screen.

I used a different Excel file (that I know is a real file), blank screen.
example.php
jxlrwtest.xls
Image8.jpg
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

InsoftserviceCommented:
XLS file provided in previous comment is corrupted.
i save  xls or csv file using simple way.

to save error_log("data1\tdata2",3,"c:/test.xls");

to read

$value =file("c:/test.xls");
print_r($value);
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
"XLS file provided in previous comment is corrupted".

That file was provided by the developer & the sample php program does not work on a real xls file either.

Why are we pursuing this non-solution at all?
Shalom CarmelCTOCommented:
Excel file formats are changing between office versions. An XLS file is not the same as a XSLX file.
Try saving as XLS, and see if it helps. Of course, this puts you in the same spot like saving to CSV....

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
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
To shalomc,

I'll try that, it's still better because the file is a workbook with several sheets; the main goal is to upload ONE file & let the php on the server do the rest.

Thanks
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
To all,

I created a test spreadsheet called Test1.xls (see attached). I modified example.php to read that file.

I changed the error reporting to what I am more familiar with.

See example.php (attached).

I ran it & got this:

entered example.php

Deprecated: Assigning the return value of new by reference is deprecated in /home/rkassoc/public_html/phpExcelReader/Excel/reader.php on line 261

Warning: require_once(Spreadsheet/Excel/Reader/OLERead.php): failed to open stream: No such file or directory in /home/rkassoc/public_html/phpExcelReader/Excel/reader.php on line 31

Fatal error: require_once(): Failed opening required 'Spreadsheet/Excel/Reader/OLERead.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rkassoc/public_html/phpExcelReader/Excel/reader.php on line 31

There is no OLERead.php; there is an OLERead.inc.

Based on this, http://sourceforge.net/p/phpexcelreader/discussion/343882/thread/1356e6c3/, I'm guessing I have to modify reader.php accordingly.

Where the directory structure "Spreadsheet/Excel/Reader/" comes from & why it's needed are a mystery to me. Since OLERead.inc is in the Excel/ directory, why can't I just modify reader.php to require_once(Excel/OLERead.inc)?

It still seems odd that a downloaded package that purports to be what it says is so full of bugs right off the bat.

Thanks
Test1.xls
example.php
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
I actually did all the things I said in my last comment; it now works.

You pointed me in the right directions.

Thanks!
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.