getActiveSheet(); // Loop through rows and columns foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); foreach ($cellIterator as $cell) { echo $cell->getValue() . "\t"; } echo "\n"; } ?>
setActiveSheetIndex(0); $worksheet = $objPHPExcel->getActiveSheet(); // Populate data $data = array( array('Name', 'Age', 'Email'), array('John Doe', 30, 'john.doe@email.com'), array('Jane Doe', 28, 'jane.doe@email.com') ); foreach ($data as $row) { $worksheet->appendRow($row); } // Save Excel file $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('example.xlsx'); ?>In both examples, we can see that PHPExcel_IOFactory is used to load and save Excel files. This library handles all of the underlying file I/O operations, so developers can focus on working with the Excel data using PHP.