1

im trying to find a way to get the rowid and columnid of an excel sheet using php, something like if($date == $row){ your $rowid = 'something}

ive seen something like

$row = $objPHPExcel->getActiveSheet()->getRowIterator($searchValue)-

>current();
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
    echo $cell->getValue();
}

but the $searchValue refers to a row, not an actual search term, i need to find current date in the sheet , the current date is on a column named date, and if i find that date get the rowid/colid, so i can write to that row and columns, i know i will always be using 6 cols of any given row, any ideas on this ? or some pointers maybe

pnuts
  • 58,317
  • 11
  • 87
  • 139
nonaxanon
  • 237
  • 4
  • 18
  • May I suggest that you take a look into the documentation of `phpexcel`? – arkascha May 29 '15 at 11:58
  • could you suggest a particular file or somehthing ? – nonaxanon May 29 '15 at 12:00
  • Well, just look at the project home page, under "Documentation" and you will come to: http://phpexcel.codeplex.com/downloads/get/809029 – arkascha May 29 '15 at 12:02
  • i know where is the documentation and even how to download it...what i need to know is what im looking for specifically is in what file or example file, so i dont lose time,,,, that is assuming you know of course if not, maybe some other person will gladly help – nonaxanon May 29 '15 at 12:05
  • Digging into and getting an overview about the documentation _always_ is well invested time, even if it does not pay out in a single incident. But you are lucky, looks like someone posted a detailed example below. – arkascha May 29 '15 at 12:07

1 Answers1

6
$row = $objPHPExcel->getActiveSheet()
    ->getRowIterator($searchValue)->current();
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
    echo 'ROW: ', $cell->getRow(), PHP_EOL;
    echo 'COLUMN: ', $cell->getColumn(), PHP_EOL;
    echo 'COORDINATE: ', $cell->getCoordinate(), PHP_EOL;
    echo 'RAW VALUE: ', $cell->getValue(), PHP_EOL;
}

or look at 28iterator.php in /Examples

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • lifesaver at its best – nonaxanon May 29 '15 at 12:06
  • @nonaxanon, This is an old thread but it is never too late to mark an answer accepted. If it helped you, it is the least you can do for the answerer. I am glad you were helped by someone other than the commenter who told you, basically, RTFM. But this community is powered on reputation. It improves both your answerer's reputation and YOUR own when you mark an answer accepted. – Anne Gunn Sep 09 '16 at 20:19
  • by the time i could not accept the given answer, cant remember why and had totally forgotten about this, if it had not been for your concern.. ;) – nonaxanon Sep 11 '16 at 17:57