Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to Read Data from Excel file, and store in variables

    Hi,

    I have some data in Excel File. Like in first cell, "name is stored", in second cell "Father name is stored", in third cell "age is stored".

    I want to read this data through php code, and want to store, "Name", "Fathername" and "Age in different variables".

    Kindly tell me that how can write this code.

    Waiting for a reply soon.

    Eshban

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know if there's an equivalent for .xls files but I usually save the excel file as a .csv file then use PHP's fgetcsv() function to gather the data.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Currently, I'm working with wordML, though quite different than excels xml output, it does have its similarities. I've tried quite a few different methods, and currently have settled with using a DOM to do my purposes. Now, the DOM is very complex if your new to php or oop in any way whatsoever, so there is also a nice addition to php5 (sorry, no version 4.x) called simpleXML, which is well... simple. Doesn't have all of the aspects of the straight dom, but is importable/exportable to it which does help. Now, I've chosen to use the dom for my uses because I'm under the understanding that its usable with version 4.3+, though haven't tested it (please, someone tell me if I'm wrong here, don't want to do what I'm doing to find out it won't work on my host :P).
    The bigger problem with microsofts excel is understanding what the elements are named for. Some are straight forward, some are not. Take something like: w:jc for instance. Yeah, that represents your texts horizontal alignment, pretty stupid name eh?
    Unfortunatly, I do not have any excel documents saved on my system as xml, and currently I'm at a 98 system so I cannot create one. If you want, I can take a look see at one tomorrow to give you an idea of what elements are for what.


    Edit: Sorry, accidently posted earlier when I wanted to open a new page :P
    Last edited by Fou-Lu; 06-08-2005 at 03:44 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •