Getting a cell value in a particular worksheet

Topics: Developer Forum, User Forum
Nov 21, 2008 at 5:22 PM
Hello.
Can someone can tell me how to get the value of cell B12 on the 3rd worksheet ?
I wrote:
require_once('include/variables.php');
include('PHPExcel/Cell/DataType.php');
include('PHPExcel.php');
include('PHPExcel/IOFactory.php');
include('PHPExcel/Writer/html.php');
?>
</head>
<
body>
<?php $objReader = PHPExcel_IOFactory::createReader("Excel2007");
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("./FG/importer.xlsx");
$objPHPExcel->setActiveSheetIndex(3);
$cell_value = $objPHPExcel->getActiveSheet()->getCell(avril_pte)->getValue();
echo "la valeur est: ".$cell_value;

and it does not unfortunately work .....

Regards

PS: avril_pte contains "B5"
Coordinator
Nov 21, 2008 at 6:07 PM
Sheet numbering starts from 0, so try $objPHPExcel->setActiveSheetIndex(2);
Incidentally, you shouldn't need to include PHPExcel/Cell/DataType.php and PHPExcel/Writer/html.php as these should be included automatically
Nov 24, 2008 at 9:04 AM
Good morning Mark
In fact the cell in on the 4th worksheet so the index set to 3 is ok.
I checked that the cell is filled in and it is.
i have absolutely no clue ....
Nov 24, 2008 at 9:07 AM
In fact I checked badly .. :-) the cell was empty.
Everything is ok.

Kind Regards