ExcelToJson is a simple and reliable PHP library that allows developers to quickly convert Excel spreadsheets into JSON format. It supports both .xls and .xlsx files and handles empty headers gracefully by automatically generating keys.
With optional output to a JSON file, it’s perfect for APIs, data migration, reporting, or any project where you need to transform Excel data into structured JSON. Designed for PHP 8+, it integrates seamlessly into your projects and comes with PHPUnit tests for easy validation.
Key Features:
----> Convert Excel files to JSON effortlessly.
----> Supports .xls and .xlsx.
----> Auto-generates keys for empty headers.
----> Pretty-printed JSON with Unicode support.
----> Optional JSON output to a file (Will be on the Next Update).
----> Compatible with modern PHP (8.0+).
Require the package via Composer:
composer require frantzley/excel-to-json<?php
require 'vendor/autoload.php';
use Frantzley\ExcelToJson\ExcelToJson;
$converter = new ExcelToJson();
// Convert Excel file to JSON
$json = $converter->convert('/path/to/your/file.xlsx'); // Replace with your file path ( ranplase li pa chemen kote fichye ou an lokalize an )
echo $json;Run unit tests with PHPUnit:
vendor/bin/phpunit testsMIT