frantzley/excel-to-mysql-web

Professional PHP package to import Excel files into MySQL with validation and upsert

Maintainers

Package info

github.com/frantzleyadolphe/excel-to-mysql-php

pkg:composer/frantzley/excel-to-mysql-web

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 1

v1.1.0 2025-09-13 03:54 UTC

This package is auto-updated.

Last update: 2026-05-04 22:57:48 UTC


README

A PHP package that allows you to import data from Excel files (.xls / .xlsx)
into a MySQL database with a full set of powerful features.
It is designed for developers and users who need fast data processing,
offering a simple UI with advanced functionalities such as live logs,
a progress bar, and log filtering.

đź›  Features

- Automatically creates the database if it does not exist.
- Automatically creates tables based on Excel headers.
- Supports Excel files with multiple sheets.
- Automatic insert/update data handling.
- Unique key support to prevent duplicates.
- Dynamic logs with filtering (insert, update, exists, error, info).
- Progress bar to track import progress.
- Connection error messages displayed in UI logs.
- Responsive UI built with Tailwind CSS and glassmorphism effects.

---

đź’» Installation


Enstale via Composer:

composer require frantzley/excel-to-mysql

Estrikti Projet an


project-root/
├─ public/
│  ├─ index.php      # Upload form and UI
│  ├─ app.js         # JavaScript file
│  ├─ process.php    # Backend processing (pre-built)
├─ src/
│  └─ ExcelToMySQL.php
├─ uploads/          # Folder for uploaded files (auto-created if not exists)
├─ vendor/           # Composer dependencies

Asire w gen PhpSpreadsheet enstale:

composer require phpoffice/phpspreadsheet

⚡ Usage

Open your browser at public/index.php.

Select your Excel file, enter the table name in the database, and define a unique key if needed.

Click Upload & Import.

Logs will appear in real time with color indicators:

Blue → new insert  
Yellow → already exists  
Red → error  

đź”§ Column Mapping

Automatic: The first row in the Excel file is used as headers; database columns will match these names.

Manual: You can customize column mapping if needed:

$importer->setMapping([
    "Excel Name"  => "db_name",
    "Excel Email" => "db_email"
]);

The table will be created automatically based on the mapping.

📦 Example pou test PHP Usage


<?php
require __DIR__ . '/vendor/autoload.php';

use Frantzley\ExcelToMySQL;

// Koneksyon PDO
$pdo = new PDO("mysql:host=localhost;dbname=testdb;charset=utf8mb4", "root", "");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// Inisyalize importer
$importer = new ExcelToMySQL("chemin/fiche.xlsx", $pdo);

// Opsyonèl: mete non tab la ak kle inik
$importer->setTableName('users');
$importer->setUniqueKey('email');

// Kreye tab si li pa egziste
$importer->createTableIfNotExists();

// Insert / Update done
$rows = $importer->getRowsFromExcel();
foreach ($rows as $row) {
    $importer->insertOrUpdateRow($row);
}

// Summary
print_r($importer->getSummary());


âš™ Requirements

PHP >= 8.0

MySQL

PhpSpreadsheet

✅ Key Point pou Itilizatè

You do not need to create process.php. All backend processing is already included in the package.

You only need to run the project and open index.php in your browser to launch the web interface, upload your Excel file, and track logs (insert / exists / error) in real time.

All required folders (uploads/) are automatically created if they do not exist.

Pake a sipòte:

1. Automatic Database Creation

If the database does not exist → it is created automatically with a log:
Database 'xxx' did not exist, it was created automatically âś…

If it already exists → it is not recreated:
Database 'xxx' already exists ⚠️

If a connection error occurs → log message:
Database connection error 'xxx': [error details] ❌

2. Automatic Table Creation

Tables are created based on Excel headers.

Empty headers are ignored.

Completely empty rows are removed.

3. Insert / Update

Inserts new rows if they do not exist.

Updates rows if the unique key already exists.

Logs display each action.

4. Dynamic Logs

Filter logs by type (insert, update, exists, error, info).

Log container adjusts height dynamically.

Auto-scroll to the latest log.

5. Progress Bar

Displays import progress based on the number of rows processed.