定制 chriskelemba/excel-import-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chriskelemba/excel-import-laravel

最新稳定版本:v0.3.0

Composer 安装命令:

composer require chriskelemba/excel-import-laravel

包简介

Dynamic CSV/XLSX import package for Laravel with generic table mapping and preview

README 文档

README

Backend package for dynamic CSV/XLSX preview and import into any configured database table.

Install

composer require chriskelemba/excel-import-laravel

Publish config

php artisan vendor:publish --tag=dynamic-importer-config

Configure (Optional)

config/dynamic-importer.php

'discovery' => [
    'allow_unconfigured_tables' => true,
    'allow_tables' => [], // optional allow-list
    'exclude_tables' => ['migrations'],
],

// Optional strict per-table overrides
'tables' => [
    'skills' => [
        'required' => ['name'],
        'unique_by' => ['name'],
        'mode' => 'upsert',
    ],
],

MongoDB Support

Install in your Laravel app:

composer require mongodb/laravel-mongodb

Configure a mongodb connection in config/database.php, then pass connection=mongodb in importer requests.

Notes:

  • SQL connections auto-discover table columns/types via schema introspection.
  • MongoDB collections are schema-less; prefer defining columns in dynamic-importer.tables.
  • If columns are not configured, importer will infer top-level keys from sample documents.

Endpoints

  • GET /imports/databases?connection=mongodb&table=loans
  • GET /imports/template?table=skills&connection=mysql
  • POST /imports/preview
  • POST /imports/run
  • POST /imports/run-multi

Preview payload

multipart/form-data:

  • file: csv/txt/xlsx
  • table: configured table name
  • connection (optional): Laravel DB connection name (e.g. mysql, mongodb)
  • column_map: map of excel_header => db_column
  • static_values (optional): fixed values applied to every imported row (e.g. ctg_id => 2)
  • header_row (optional, 1-based)
  • sheet_index (optional, default 0)
  • sample_rows (optional)

Run payload

multipart/form-data:

  • file
  • table
  • connection (optional)
  • column_map
  • static_values (optional object)
  • header_row (optional)
  • sheet_index (optional)
  • mode (optional: insert or upsert)
  • unique_by (optional array for upsert)

Multi-table run payload

multipart/form-data:

  • file
  • connection (optional global connection)
  • imports[0][table]
  • imports[0][column_map][Loan No]
  • imports[0][column_map][Customer]
  • imports[0][mode]
  • imports[0][unique_by][0]
  • imports[0][static_values][ctg_id] (optional fixed value / foreign key)
  • imports[1][table]
  • imports[1][column_map][...]

Database preview

Use GET /imports/databases to drive UI selectors:

  • connection (optional): selected database connection (mysql, mongodb, ...)
  • table (optional): returns selected table/collection definition including columns

Notes

  • CSV support works out of the box.
  • XLSX support requires phpoffice/phpspreadsheet.
  • XLSX preview grid includes style/merge metadata (style, rowspan, colspan, skip) when available from reader output.
  • By default, any existing DB table can be imported (dynamic schema discovery).
  • Use discovery.allow_tables / discovery.exclude_tables for restrictions.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固