PhpSpreadsheet is a PHP library for reading and writing spreadsheet files. Import Excel and CSV into MySQL help to save the user time and avoid repetitive work. PHP version 7.2 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by the composer. composer require phpoffice/phpspreadsheet
phpspreadsheet
library inside in your controller
The following SQL query creates a user_info
table in the MySQL database.
CREATE TABLE `client_info` [
`id` int[10] NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` varchar[255] COLLATE utf8mb4_unicode_ci NOT NULL,
`country_code` varchar[10] COLLATE utf8mb4_unicode_ci NOT NULL,
`mobile` varchar[100] COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar[255] COLLATE utf8mb4_unicode_ci NOT NULL,
`city` varchar[255] COLLATE utf8mb4_unicode_ci NOT NULL,
`ip_address` varchar[100] COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT current_timestamp[] ON UPDATE current_timestamp[],
`status` int[10] NOT NULL
] ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Open App/Config/Routes.php
file and add following lines.
Create a model file named UserModel.php inside the App/Models
folder.