require_once 'PHPExcel/Classes/PHPExcel.php'; // Load the spreadsheet file $excel = PHPExcel_IOFactory::load('example.xlsx'); // Retrieve the "Sheet2" worksheet $worksheet = $excel->getSheetByName('Sheet2'); // Do something with the worksheet (e.g. get cell values) $value = $worksheet->getCell('A1')->getValue();
require_once 'PHPExcel/Classes/PHPExcel.php'; // Load the spreadsheet file $excel = PHPExcel_IOFactory::load('example.xlsx'); // Check if "Sales" worksheet exists if ($excel->sheetNameExists('Sales')) { // Retrieve the "Sales" worksheet $worksheet = $excel->getSheetByName('Sales'); // Do something with the worksheet (e.g. get cell values) $value = $worksheet->getCell('A1')->getValue(); } else { echo "Worksheet not found!"; }In both examples, we use the PHPExcel package/library to load and manipulate the spreadsheet file.