Giter Site home page Giter Site logo

laclance / laravel-excel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spartnernl/laravel-excel

0.0 2.0 0.0 2.04 MB

馃殌 Supercharged Excel exports and imports in Laravel

Home Page: https://laravel-excel.maatwebsite.nl/

License: MIT License

PHP 99.90% HTML 0.10%

laravel-excel's Introduction

Laravel Excel

Laravel Excel 3.1

Laravel Excel

馃帀 Celebrating 5 years of Laravel Excel. Read more on our blog!

馃挭 馃敟 馃殌

Supercharged Excel exports and imports
A simple, but elegant wrapper around PhpSpreadsheet with the goal of simplifying exports and imports.

Build Status StyleCI Latest Stable Version Total Downloads License

  • Easily export collections to Excel. Supercharge your Laravel collections and export them directly to an Excel or CSV document. Exporting has never been so easy.

  • Supercharged exports. Export queries with automatic chunking for better performance. You provide us the query, we handle the performance. Exporting even larger datasets? No worries, Laravel Excel has your back. You can queue your exports so all of this happens in the background.

  • Supercharged imports. Import workbooks and worksheets to Eloquent models with chunk reading and batch inserts! Have large files? You can queue every chunk of a file! Your entire import will happen in the background.

  • Export Blade views. Want to have a custom layout in your spreadsheet? Use a HTML table in a Blade view and export that to Excel.

馃殌 5 minutes quick start for exports

馃挕 Require this package in the composer.json of your Laravel project. This will download the package and PhpSpreadsheet.

composer require maatwebsite/excel

馃挭 Create an export class in App/Exports

php artisan make:export UsersExport --model=User

This should have created:

<?php

namespace App\Exports;

use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;

class UsersExport implements FromCollection
{
    public function collection()
    {
        return User::all();
    }
}

馃敟 In your controller you can call this export now:

use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;

class UsersController extends Controller 
{
    public function export() 
    {
        return Excel::download(new UsersExport, 'users.xlsx');
    }
}

馃搫 Find your users.xlsx in your downloads folder!

More installation instructions can be found at: https://laravel-excel.maatwebsite.nl/3.1/getting-started/installation.html

馃殌 5 minutes quick start for imports

馃挭 Create an import class in App\Imports

You may do this by using the make:import command.

php artisan make:import UsersImport --model=User

If you prefer to create the import manually, you can create the following in App\Imports:

<?php

namespace App\Imports;

use App\User;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;

class UsersImport implements ToModel
{
    /**
     * @param array $row
     *
     * @return User|null
     */
    public function model(array $row)
    {
        return new User([
           'name'     => $row[0],
           'email'    => $row[1], 
           'password' => Hash::make($row[2]),
        ]);
    }
}

馃敟 In your controller you can call this import now:

use App\Imports\UsersImport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;

class UsersController extends Controller 
{
    public function import() 
    {
        Excel::import(new UsersImport, 'users.xlsx');
        
        return redirect('/')->with('success', 'All good!');
    }
}

馃搫 Find the imported users in your database!

馃帗 Learning Laravel Excel

You can find the full documentation of Laravel Excel on the website.

We welcome suggestions for improving our docs. The documentation repository can be found at https://github.com/Maatwebsite/laravel-excel-docs.

Read some articles and tutorials can be found on our blog: https://laravel-excel.maatwebsite.nl/blog/

馃敡 Supported Versions

Versions will be supported for a limited amount of time.

Version Laravel Version Php Version Support
2.1 <=5.6 <=7.0 Unsupported since 15-5-2018
3.0 ^5.5 ^7.0 Security fixes till 31-12-2018
3.1 ^5.5 ^7.0 New features

馃摤 License & Postcardware

Our software is open source and licensed under the MIT license.

If you use the software in your production environment we would appreciate to receive a postcard of your hometown. Please send it to:

Maatwebsite
Florijnruwe 111-2
6218 CA Maastricht
The Netherlands

More about the license can be found at: https://laravel-excel.maatwebsite.nl/3.1/getting-started/license.html

laravel-excel's People

Contributors

brandondrew avatar devinfd avatar drakakisgeo avatar driesvints avatar frankpeters avatar glennm avatar grahamcampbell avatar gregpeden avatar hicode avatar jeroenvossen avatar maatwebsitesupport avatar maddhatter avatar mewben avatar mikesir87 avatar moura137 avatar ogg1980 avatar opb avatar pablobernardo avatar patrickbrouwers avatar pborreli avatar poyeyo avatar radostin avatar rhofma avatar rhynodesigns avatar srobati avatar ssfinney avatar thallisphp avatar tomvbe avatar trouttdev avatar yama-ver2 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google 鉂わ笍 Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.