Reputation: 17705
Imagine an Excel file with 2 columns like below:
Name Surname
John Some surname
Matt Another surname
Steve Again something
Is there a way to get a value of the cell by column name and row number? Something like this:
$worksheet->getCellByColumnNameAndRowValue('Name', 1)->getValue(); // gives John
Right now I'm using an array that maps column names to column numbers and getCellByColumnAndRow
function but I wonder if there's a simpler solution.
Upvotes: 1
Views: 3717
Reputation: 212402
No there isn't, because 'Name' is just a string cell value (the value in cell 'A1') to PHPExcel, it isn't a column name (that would be column 'A')
What you could do would be to specify a Named Range called 'Name' (or 'Surname', or whatever)... then you could use the namedRangeToArray() method to return the values of all cells in the named range as an array.
Upvotes: 1