PHP to produce graphs based on data from Excel spreadsheet

Hello,

I am trying to find a way to build a graph based on the data found in an excel spreadsheet. I have found some code here...

building graphs with PHP from spreadsheets

I have got it working with the example given but now I want to develop it further. I want to select certain data from the spreadsheet rather than just selecting everything in the array.

The code I currently have is:-

Code:

`<?php`

function datascript() {

$dataLines = array();

// initialise the spreadsheet reader

require_once 'reader.php';

$reader = new Spreadsheet_Excel_Reader();

// Set output Encoding.

$reader->setOutputEncoding('CP1251');

// read in the spreadsheet

$reader->read('../../graphtest/wellcomm.xls');

// place the data from the spreadsheet into

// the dataLines array for use by the graph software

// the first column and first row of our spreadsheet are

// labels and so we will ignore these

// i.e. we will begin reading data from column 2 and row 2

$dataLines = array();

for ($i = 2; $i <= $reader->sheets[0]['numRows']; $i++) {

for ($j = 2; $j <= $reader->sheets[0]['numCols']; $j++) {

$dataNum = $i-1;

$seriesNum = $j-1;

$dataLines[] = "data".$dataNum."series".$seriesNum.": ".$reader->sheets[0]['cells'][$i][$j];

}

}

// return the data lines array to the graphing software

return $dataLines;

}

// Make sure there are no characters (not even a space or return character)

// after the following line

?>

This is the default Data Function.php file found on the above site. How can I manipulate the array to retrieve rows 2-26 and only columns 1 and 5?

I think I know what is needed to do but don't know how to write it? I am guessing you need to put a count on the $j part for the rows but no idea on the columns.

Can anyone help me with this? :)

TIA