Read Excel with PHP

Using Excel for anything other than quick data tabulation is usually a bad idea. If you use a spreadsheet the way you should use a database, you are just asking for trouble. Unfortunately, in the world of accounting organizing information in excel sheets is a common practice.

Sooner or later a manager will get tired want to see a report based on that spreadsheet, and have it tie into your online time tracking and billing system. So they call up the IT, and say “make it so, #1″.

How do you make it happen? For one, I decided not to reinvent the wheel. I figured that the less code I write, the less bugs I introduce to my already kludge prone web app. Laziness is a very favorable trait for a programmer! It encourages code reuse and modularity )

So I grabbed the PHP Excel Reader from freashmeat. For the last hour I have been playing with it, and essentially implemented half of the required application. I don’t even want to think how many hours would it take me to develop XLS parser from scratch.

Thank you freshmeat!

Update Thu Jul 13 11:54:06 EDT 2006

You should probably look at the brief documentation at sourceforge. Be aware that this app treats formulas as blank cells. For my purposes this is ok so I don’t really care.

By default dates are displayed in the European format (dd/mm/yy). To use American dates instead change line 88 in reader.php to:

0xe => "m/d/Y",

I hope this helps

Related Posts:

  • Dump MySQL table into CSV file
  • PHP: Export Query Results to a CSV File
  • Excel in-cell Bar Charts
  • Convert a large Access table into Excel files
  • Excel: Too many different cell formats
  • Parsing Excel Files with Perl
  • Cory Doctorow is the Man
  • How to talk to users?
  • Project Idea
  • What kind of applications do you have open right now?

  • 3 Responses to “Read Excel with PHP”

    1. Gravatar Sarika INDIA Says: Reply to this comment

      Can you send us the format for

      dd/mm/yyyy

      Posted using Internet Explorer Internet Explorer 7.0 on Windows Windows XP
    2. Gravatar Luke UNITED STATES Says: Reply to this comment

      This question would probably be best sent to the original developer. I will look at the code tomorrow, but I’m assuming that putting that string on the 0xe line didn’t work… If you haven’t tried it, go do it now.

      Quick and dirty hack would be simply look at the fist digit of the year and assume that if it is greater than say 4 then assume that you are dealing with 1900’s - otherwise you are dealing with 2000’s.

      Of course this means that your application will break in 2040 but you know… P

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.2 on Windows Windows XP
    3. Gravatar Adham CANADA Says: Reply to this comment

      I have just recently finished setting phpExcelReadr for my intranet, and it reads the data and displays it perfectly. Nevertheless, my only concern is that it also prints and row/col numbers/letters. I am trying to have it disregard them and treat the first row as a header (for cosmetic purposes). Would you have any idea about the go around in achieving this result? Any suggestions and/or assistance will be really appreciated.

      Posted using Internet Explorer Internet Explorer 7.0 on Windows Windows Server 2003

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <pre lang=""> <em> <i> <strike> <strong>

    [Quote selected]