Jump to content

Get values from a EXCEL sheet by using PHP


Recommended Posts

Hi guys,


here is what I have:


  • an excel sheet (XLS, 4MB) with postal codes in the first column
  • more data in the other columns


here is what I need:


  • looking for the postal code in the excel sheet
  • get the information to this postal code from the other columns
  • work with the other information (use them as variables)




PC | A | B | C

1234 | 2.3 | 3.5 | 1.1

2345 | 3.3 | 3.3 | 7.8


---> If I have the postal code 2345, I want to create the variables $a=3.3 ; $b=3.3 ; c=7.8 in PHP



here is what I heard about:


  • phpexcel.php
  • php_excelReader

here are my questions:


What would you recommend (phpexcel.php or php_excelReder or something else)?


Is there a tutorial on w3schools (I couldn´t find one)?


Can you provide some code?



Thanks for your help!



Link to comment
Share on other sites

Got it :)

<?php$csv = array();$file = fopen('myfile.csv', 'r');while (($result = fgetcsv($file)) !== false){    $csv[] = $result;}/*******************************************/$i="0";for ($c=0; $csv[$c][0] =< $postalcode; $c++){$i=$i+1;       }$postalcoderow = $i;/*******************************************/fclose($file);/*echo '<pre>';print_r($csv[$postalcoderow][$columnnumber]);echo '</pre>';*/?> 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...