代码之家  ›  专栏  ›  技术社区  ›  user900

从phpEXcel中的值获取单元格地址

  •  1
  • user900  · 技术社区  · 7 年前

    我正在使用PHPExcel库读取Excel文件并对其执行处理。 我对提取手机地址有一些疑问。

    excel示例:

    id |姓名|年龄
    191 |卖方| 25
    192 |买方| 69
    193 | Amith | 40

    我需要取“买家”的手机地址。 我知道它在“Name”标题下,id是192。 谁能帮我取一下手机地址吗。。。

    1 回复  |  直到 4 年前
        1
  •  0
  •   boroboris    7 年前

    试试这个:

    $cell_coordinates = '';
    
    foreach ($objWorksheet->getRowIterator() as $row) {
        $row_number = $row->getRowIndex();
    
        foreach ($row->getCellIterator() as $cell) {
            $cellValue = $cell->getCalculatedValue();
    
            if($cellValue === 'Buyer' && $row_number === 192) {
                $cell_coordinates = $cell->getColumn() . '192';
            }
        }
    }