我正在使用PHPExcel从xls
文件中读取一些数据。
我想同时得到几个细胞,比如:A6-A11。
我知道我可以使用$cell = $objPHPExcel->setActiveSheetIndex(0)->getCell('A6');
来获得一个单元格,我可能可以循环遍历一个数组,并获得我范围内的每个单元格。
但是,难道没有一种更简单的方法来获得一系列类似getCellRange('A6:A11')
的细胞吗?
有,rangeToArray()
方法:
$objPHPExcel->setActiveSheetIndex(0)->rangeToArray('A1:C3');
我想知道为什么我一开始就麻烦记录这些方法,但这里也有一个论点列表:
/**
* Create array from a range of cells
*
* @param string $pRange Range of cells (i.e. "A1:B10"),
* or just one cell (i.e. "A1")
* @param mixed $nullValue Value returned in the array entry
* if a cell doesn't exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows
* and columns indexed by number counting
* from zero
* True - Return rows and columns indexed by
* their actual row and column IDs
* @return array
*/