listratov
listratov

Reputation: 65

How to display the names of the sheets of xls file using PHPexcel?

How to display the names of the sheets of xls file using PHPexcel?

$objWorksheet = $objPHPExcel->setActiveSheetIndex(0); ???

Upvotes: 1

Views: 13272

Answers (2)

Chintan
Chintan

Reputation: 1

its return all sheet in an array

    $this->load->library('PHPExcel/Classes/PHPExcel');
    $excelReader = PHPExcel_IOFactory::createReaderForFile($fileTempName);
    $excelObj = $excelReader->load($fileTempName);
    //$worksheet = $excelObj->getSheet(0);
    $worksheet = $excelObj->getSheetNames();

    echo "<pre>";
    print_r($worksheet);
    die;

Upvotes: 0

Mark Baker
Mark Baker

Reputation: 212412

$objPHPExcel->getSheetNames();

will return a list of all worksheet names

$objWorksheet->getTitle();

will return the name of the worksheet in $objWorksheet

EDIT

How to access a sheet by name/title:

$objWorksheet = $objPHPExcel->getSheetByName('Worksheet1'); 

Upvotes: 3

Related Questions