PHPExcel如何仅获取1个单元格值? [英] PHPExcel How to get only 1 cell value?
问题描述
我认为getCell($X, $y)
或getCellValue($X, $y)
可用于轻松选择某个值.这可能很有用,例如在进行较大处理之前先进行交叉检查数据.
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 example crosscheck data prior to a larger process.
如何从单元格 C3 中获取特定值.
How do you get a specific value from say cell C3.
我不希望对值数组进行排序.
I do not want an array of values to sort through.
推荐答案
开发人员文档的第4.5.2节
Section 4.5.2 of the developer documentation
通过坐标检索单元格
要检索单元格的值,首先应使用getCell方法从工作表中检索该单元格.可以使用以下代码行再次读取单元格的值:
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();
开发者文档的第4.5.4节
Section 4.5.4 of the developer documentation
按列和行检索单元格
要检索单元格的值,首先应使用getCellByColumnAndRow方法从工作表中检索该单元格.可以使用以下代码行再次读取单元格的值:
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();
如果需要计算单元格的值,请使用以下代码. 4.4.35
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();
这篇关于PHPExcel如何仅获取1个单元格值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!