我试图找到一种方法来使用php获取excel表格的rowid和columnid,类似于if($date == $row){ your $rowid = 'something}
我见过像
这样的东西$row = $objPHPExcel->getActiveSheet()->getRowIterator($searchValue)-
>current();
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
echo $cell->getValue();
}
但$ searchValue引用的是一行,而不是实际的搜索词,我需要在工作表中找到当前日期,当前日期在名为date的列上,如果我发现该日期获取rowid / colid,所以我可以写到那行和列,我知道我将永远使用任何给定行的6列,任何想法吗?或者一些指针可能
答案 0 :(得分:5)
$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;
}
或查看28iterator.php
/Examples