$objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel = PHPExcel_IOFactory::load("example.xlsx"); $objPHPExcel->setActiveSheetIndex(2);In example 1, a new workbook is created using PHPExcel and the active sheet is set to the second sheet using the setActiveSheetIndex() method. In example 2, an existing Excel file is loaded using PHPExcel_IOFactory and the active sheet is set to the third sheet using the setActiveSheetIndex() method. The package library used in these examples is PHPExcel.