Code Monkey home page Code Monkey logo

laravel-csv-export's Introduction

Laravel CSV Export

Export a Large Dataset in CSV Format. It is based on Symfony’s StreamedResponse and Laravel’s chunked queries.

Current version: [v1.0.4]

Installation

Via Composer

$ composer require clivern/lce

Then add the ServiceProvider to the providers array in config/app.php

'providers' => [
    // ...
    Clivern\Lce\LceServiceProvider::class,
    // ...
],

You can use the facade for shorter code. Add this to your aliases:

'aliases' => [
    // ...
    'Lce' => Clivern\Lce\Facades\Lce::class,
    // ...
],

The class is bound to the ioC as lce

$lce = App::make('lce');

Usage

For Example Let's use it to export options table.

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Option; # Eloquent Model
use Validator;
use Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;


class HomeController extends Controller
{

    public function indexRender()
    {

        return \App::make('lce')
            ->file('options')
            ->source(new Option)
            ->chunks(10)
            ->header([["Id","Option Key","Option Value"], ['', '', '']])->callback(function($option){
                return [
                    $option->id,
                    $option->op_key,
                    $option->op_value,
                ];
            })->export();
    }
}

Change log

Version 1.0.4:
> Composer lock file added.

Version 1.0.3:
> New method to get CSV file content.
> New feature to add two rows in single return.

Version 1.0.2:
> Docs Updated.

Version 1.0.1:
> Docs Updated.
> UTF-8 Support Added.

Version 1.0.0:
> Initial Release.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

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

laravel-csv-export's People

Contributors

clivern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

forks

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.