PHPExcel How to get only 1 cell value?

前端 未结 3 1563
误落风尘
误落风尘 2020-12-09 16:55

I would think that a getCell($X, $y) or getCellValue($X, $y) would be available for one to easily pick a a certain value. This can be usefully, as

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 17:58

    Section 4.5.2 of the developer documentation

    Retrieving a cell by coordinate

    To retrieve the value of a cell, the cell should first be retrieved from the worksheet using the getCell method. A cell’s value can be read again using the following line of code:

    $objPHPExcel->getActiveSheet()->getCell('B8')->getValue();
    

    Section 4.5.4 of the developer documentation

    Retrieving a cell by column and row

    To retrieve the value of a cell, the cell should first be retrieved from the worksheet using the getCellByColumnAndRow method. A cell’s value can be read again using the following line of code:

    // Get cell B8
    $objPHPExcel->getActiveSheet()->getCellByColumnAndRow(1, 8)->getValue();
    

    If you need the calculated value of a cell, use the following code. This is further explained in 4.4.35

    // Get cell B8
    $objPHPExcel->getActiveSheet()->getCellByColumnAndRow(1, 8)->getCalculatedValue();
    

提交回复
热议问题