Jump to content
Sign in to follow this  
Chrex

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)

 

example:

 

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!

 

 

Share this post


Link to post
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>';*/?> 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...