承接 mohd-arbaaz/laravel-excel-wrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mohd-arbaaz/laravel-excel-wrapper

Composer 安装命令:

composer require mohd-arbaaz/laravel-excel-wrapper

包简介

A unified API for Excel imports and exports in Laravel, supporting both Maatwebsite/Excel and OpenSpout.

README 文档

README

Latest Version on Packagist Total Downloads License

A unified API for Excel imports and exports in Laravel, supporting both Maatwebsite/Excel (rich features) and OpenSpout (high performance).

Features

  • 🎯 Unified Column Definition - Define columns once using ColumnDef data objects
  • 🔄 Two Drivers - Choose between Maatwebsite/Excel (styling, formulas) or OpenSpout (speed, memory efficiency)
  • Built-in Validation - Laravel validation rules integrated into imports
  • 📊 Multi-Sheet Support - Export and import multiple sheets in a single file
  • 🎨 Conditional Formatting - Color coding based on values (Maatwebsite only)
  • 📦 Chunked Processing - Handle large files efficiently
  • 🔧 Type Transformations - Automatic formatting for dates, booleans, amounts, etc.

Installation

composer require mohd-arbaaz/laravel-excel-wrapper

Then install at least one of the underlying drivers:

# For Laravel Excel (rich features, styling)
composer require maatwebsite/excel

# For OpenSpout (high performance, low memory)
composer require openspout/openspout

Publish Configuration (Optional)

php artisan vendor:publish --tag=excel-wrapper-config

Quick Start

Export Example

use ExcelWrapper\Abstracts\LaravelExcelExport;
use ExcelWrapper\Data\ColumnDef;
use Illuminate\Support\Collection;

class UsersExport extends LaravelExcelExport
{
    public function columnConfig(): Collection
    {
        return collect([
            ColumnDef::make('name', 'Full Name')->string()->width(25),
            ColumnDef::make('email', 'Email Address')->string()->width(30),
            ColumnDef::make('balance', 'Account Balance')
                ->amount()
                ->colored()
                ->width(15),
            ColumnDef::make('created_at', 'Joined')
                ->date()
                ->width(15),
        ]);
    }

    public function collection(): ?Collection
    {
        return User::all();
    }
}

// Usage
return (new UsersExport)->download('users.xlsx');

Import Example

use ExcelWrapper\Abstracts\LaravelExcelImport;
use ExcelWrapper\Data\ColumnDef;
use Illuminate\Support\Collection;

class UsersImport extends LaravelExcelImport
{
    public function columnConfig(): Collection
    {
        return collect([
            ColumnDef::make('name', 'Name')
                ->string()
                ->rules('required|string|max:255'),
            ColumnDef::make('email', 'Email')
                ->string()
                ->rules('required|email|unique:users,email'),
            ColumnDef::make('balance', 'Balance')
                ->amount()
                ->rules('nullable|numeric'),
        ]);
    }

    public function onRow(array $row): void
    {
        User::create($row);
    }
}

// Usage
$result = (new UsersImport)->import('users.xlsx');

if ($result->hasErrors()) {
    foreach ($result->errors as $error) {
        echo "Row {$error['row']}: {$error['field']} - {$error['messages'][0]}";
    }
}

Choosing a Driver

FeatureLaravel ExcelOpenSpout
Styling✅ Full support❌ Limited
Conditional Formatting✅ Yes❌ No
Formulas✅ Yes✅ Basic
Memory UsageHigher✅ Low
Speed (large files)Slower✅ Fast
Multi-sheet✅ Yes✅ Yes

Use Laravel Excel when:

  • You need styling, conditional formatting, or complex formulas
  • File sizes are moderate (< 50k rows)
  • You need Excel-specific features

Use OpenSpout when:

  • Processing large files (100k+ rows)
  • Memory is constrained
  • You don't need advanced styling

Switching Drivers

Simply change the base class - the columnConfig() and data methods remain the same:

// Laravel Excel
use ExcelWrapper\Abstracts\LaravelExcelExport;
class UsersExport extends LaravelExcelExport { ... }

// OpenSpout
use ExcelWrapper\Abstracts\OpenSpoutExport;
class UsersExport extends OpenSpoutExport { ... }

Documentation

Requirements

  • PHP 8.2+
  • Laravel 11+ or 12+
  • spatie/laravel-data ^4.0

Driver Requirements:

  • maatwebsite/excel ^3.1 (for Laravel Excel driver)
  • openspout/openspout ^4.0 (for OpenSpout driver)

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email arbaaz@example.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固