Read specific Columns only?

Topics: User Forum
Feb 25, 2010 at 4:47 PM

I am reading through the documentation on PHPExcel today and like the idea of reading specific cells only using class MyReadFilter, but the example only shows reading certain rows. Is it possible to read all the rows of certain columns?

I tried $columns <= 3 on the 28iterator example but it keeps just showing me A1 in my sample dataset.


Feb 25, 2010 at 9:33 PM
class MyReadFilter implements PHPExcel_Reader_IReadFilter
	private static validColumns = array('A','B','C');

	 * Should this cell be read?
	 * @param 	$column		String column index
	 * @param 	$row			Row index
	 * @param	$worksheetName	Optional worksheet name
	 * @return	boolean
	public function readCell($column, $row, $worksheetName = '') {
		if (in_array($column,self::validColumns)) {
			return true;
		return false;
	}	//	function readCell
}	//	class MyReadFilter

$filter = new MyReadFilter()
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("MyExcelFile.xls");