getCell() returns entire row

Topics: Developer Forum, User Forum
Oct 23, 2013 at 10:15 PM
Edited Oct 23, 2013 at 11:38 PM
I am reading data from a simple spreadsheet but getCell() returns all the data from a row and not just the indicated cell.

For example, I have a spreadsheet with random text in the first few cells.
   __A__ __B__ __C__ __D__ __E__
1 | aa  | bb  | cc  | dd  | ee  |
2 |     |     |     |     |     |
I fire up PHPExcel and run this code:
$objReader = PHPExcel_IOFactory::createReaderForFile($file);
$objPHPExcel = $objReader->load($file);

$foo = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow('A', 1)->getValue();
$bar = $objPHPExcel->getActiveSheet()->getCell('A1')->getValue();
The result for both $foo and $bar is one string of all the values:
aa   bb   cc   dd   ee
Why is this happening? Thanks.

PHP v5.3.13
PHPExcel v1.7.9
Oct 25, 2013 at 8:18 AM
What is the real type of your file (that returns PHPExcel_IOFactory::identify($file))?
This kind of phenomenon is reminiscent to a CSV/text file whose delimiters are not correctly defined.
Oct 25, 2013 at 10:05 PM
LWol, you're exactly right. The spreadsheet is from a third-party and has the standard .XLS extension. However identify() returns 'CSV' and the spreadsheet can be interpreted using fgetcsv(). Thanks a lot for the help!