count worksheet and display name

Apr 30, 2010 at 3:35 PM

Hi all,

Please help to count worksheet in Excel file and display their names.

 

Thanks for you time,

K

Coordinator
Apr 30, 2010 at 4:06 PM
$fileName = "MyExcelFile.xls";
require_once '../Classes/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load($fileName);
$sheetCount = $objPHPExcel->getSheetCount();
$sheetNames = $objPHPExcel->getSheetNames();
echo 'There are ',$sheetCount,' worksheets<br />They are called:<br />';
foreach($sheetNames as $sheetName) {
    echo $sheetName,'<br />';
}

These methods are obvious if you look at the API docs

Apr 30, 2010 at 4:09 PM

Thank you for your time, MarkBaker