My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
fillCell  
Updated Feb 4, 2010 by kazu....@gmail.com

Method:fillCell

cell value filler

replaces the value of a specific cell

sample of a csv file "my_cool.csv"

name,age,skill
john,13,knows magic
tanaka,8,makes sushi
jose,5,dances salsa

php implementation

$csv = new File_CSV_DataSource;

// load the csv file
$csv->load('my_cool.csv');

// find out if the given coordinate is valid
if($csv->hasCell(1, 1)) {

// if so grab that cell and dump it
var_export($csv->getCell(1, 1));       // '8'

// replace the value of that cell
$csv->fillCell(1, 1, 'new value');  // true

// output the new value of the cell
var_export($csv->getCell(1, 1));       // 'new value'

}

now lets try to grab the whole row

// show the whole row
var_export($csv->getRow(1));

standard output

array (
0 => 'tanaka',
1 => 'new value',
2 => 'makes sushi',
)
  1. Argument integer $x the row to fetch
  2. Argument integer $y the column to fetch
  3. Argument mixed $value the value to fill the cell with
  • Visibility public
  • Returns boolean
  • Also see hasCell(), getRow(), getRows(), getColumn()

Sign in to add a comment
Powered by Google Project Hosting