Set active sheet by name

Mar 17, 2009 at 4:12 PM

Hi there,

Is it possible to call a sheet by its name rather than its index?

So normally I would use

$objPHPExcel->setActiveSheetIndex(0);

but what I want to do is to call the sheet by name eg

$objPHPExcel->setActiveSheetIndex('sheetname');

but this does not work... any ideas?

thanksandy

Developer
Mar 17, 2009 at 4:27 PM
This should do the trick for now:

$objPHPExcel->setActiveSheetIndex($objPHPExcel->getIndex($objPHPExcel->getSheetByName('sheetname')));

Mar 17, 2009 at 4:36 PM
lol,

genious, gald i asked as I would never have figured that out

thanks