require_once 'path/to/PHPExcel/IOFactory.php'; $inputFileName = 'path/to/excel/file.xlsx'; $reader = PHPExcel_IOFactory::createReaderForFile($inputFileName); $reader->setReadDataOnly(true); $excel = $reader->load($inputFileName); $sheet = $excel->getActiveSheet(); $data = $sheet->toArray(); // Use $data array for further processing
require_once 'path/to/PHPExcel/IOFactory.php'; $inputFileName = 'path/to/csv/file.csv'; $reader = PHPExcel_IOFactory::createReader('CSV'); $reader->setDelimiter(','); $reader->setEnclosure('"'); $data = $reader->load($inputFileName)->getActiveSheet()->toArray(); // Use $data array for further processingHere, we create a new reader object specifically for the CSV file format using the createReader method. We then set the delimiter and enclosure options to match the CSV file format. Finally, we load the file using the reader object, retrieve the active sheet, and convert the sheet data into a PHP array. Overall, PHPExcel_IOFactory createReader is a powerful utility for reading data from spreadsheet files in PHP, and it is part of the PHPExcel package library.