How To Get the sheet names?

Topics: Developer Forum, User Forum
Mar 19, 2013 at 4:56 AM
Hi all, I've been looking for any tutorial for PHPExcel 1.7.8 to work with my newest version of Codeigniter on Win 7.
It's working, actually, but I'm looking to get the sheet names. On the documentation, the sheet names are declared. But I want the PHPExcel to read it from the excel file. Because on my company, each user uploads excel file with different sheet names with other person based on their responsibilities.

To be simple:

In my case, if the sheet names is "A", then I would do the function do_A(); It will insert the table A
If the sheet names is "B", function do_B() will do the process to the table B...
sheet names "C", do_C() as well...

I've read the documentation but I'm still confused...
Any help?

Thank you so much...
-ghijoon
Mar 19, 2013 at 8:11 AM
Use method getTitle() of worksheet object.
Mar 19, 2013 at 1:27 PM
you can also use
$objReader->listWorksheetNames($file);
to get an array of all sheet names in the file
Mar 20, 2013 at 8:15 AM
Massi wrote:
you can also use
$objReader->listWorksheetNames($file);
to get an array of all sheet names in the file
That's it! I find it easier using this.
Now My codes are:
$sheets = $read->listWorksheetNames($filepath);
foreach($sheets as $sheetname){
    switch ($sheetname)
            {
                case 'A':
                    $_sheet = $excel->setActiveSheetIndexByName($sheet);
                    $this->do_A($_sheet);
                        break;
                case 'B':
                    $_sheet = $excel->setActiveSheetIndexByName($sheet);
                    $this->do_B($_sheet);
                break;
                case 'C':
                    $_sheet = $excel->setActiveSheetIndexByName($sheet);
                    $this->do_C($_sheet);
                break;
                                default:
                        $this->do_D();
                break;
}
Thank you again for giving me a hint how to do it quickly and better.

@LWol
Thank you for the responses,
After an hour of writing codes finally the codes are done...

Thank you all