get Worksheets Titles

Topics: Developer Forum, User Forum
Oct 15, 2010 at 9:45 AM

I searched all over and I couldn't find any way to read the Worksheets titles?

Can PHPExcel do that?


I am reading random excels (Excel5) and I have db table difined by the name of the worksheets but I cannot read the worksheet title.

Oct 15, 2010 at 10:25 AM

To read a list of all worksheet titles in a workbook:

echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
$loadedSheetNames = $objPHPExcel->getSheetNames();
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
    echo $sheetIndex,' -> ',$loadedSheetName,'<br />';

To read the name of the current worksheet:

$sheetName = $objPHPExcel->getActiveSheet()->getTitle();

Oct 15, 2010 at 10:35 AM

Thank you verry much - I didn't find it in the documentation.

Oct 15, 2010 at 6:40 PM

All the classes with their properties and methods are described in the API documentation. You can find it in the API subdirectory of your /Documentation directory in the distribution set: just point your web browser at it, and it should pick up the index automatically.