Read Data from MS Excel (XLSX) File using PHP

phpoffice/phpspreadsheet library

  1. Add phpoffice/phpspreadsheet library to composer.json file:
"require": { "phpoffice/phpspreadsheet": "^1.14" }
  1. Install library from the command line:
composer install
  1. Read data from MS Excel (XLSX) file:
<?php use PhpOffice\PhpSpreadsheet\IOFactory; require_once __DIR__.'/vendor/autoload.php'; $spreadsheet = IOFactory::load('test.xlsx'); $sheet = $spreadsheet->getActiveSheet(); $data = $sheet->toArray(); print_r($data);

Leave a Comment

Cancel reply

Your email address will not be published.