Count columns and rows when reading .xls

Topics: Developer Forum, Project Management Forum, User Forum
May 11, 2010 at 8:37 PM

Hi guys many thanks for this magnificent API, since i am a CS student i need a little help. I haven't found till now how to count the number of columns and rows when i read a .xls file.

I use something like the following

require_once '../Classes/PHPExcel.php';

/** PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';
//$objReader = new PHPExcel_Reader_Excel5();
$objReader =PHPExcel_IOFactory::createReaderForFile($file);
$objPHPExcel = $objReader->load($file);

//$sheet = $objPHPExcel->getActiveSheet();

I tried getSheetIndex() but no effect.
Also i need
with a loop like foreach or for($i=0; $i<=$NoCols), to use the values (names of xls columns) in a create stetement as the names of fields for the db table.
Any help would be greatly appreciated, thanks in advance!


May 15, 2010 at 12:09 PM

I'm not sure I really understand what you're asking, but take a look at the row and column iterators (example code in /Tests/28iterator.php)