GithubHelp home page GithubHelp logo

super-simple-excel's Introduction

Super simple excel

Simple package for creating an Excel file from arrays, traversable objects or Eloquent Collections when you dont need advanced configuration on cell level.

Installation

This package can be installed via Composer:

composer require dmoen/super-simple-excel

Usage

Basic example

$writer = ExcelWriter::create()
    ->setHeadings(["Lorem", "Ipsum", "Sit", "Amet"]);

$writer->addContent(["Row1", "Row1", "Row1", "Row1"]); 
    
$writer->addContent(["Row2", "Row2", "Row2", "Row2"])
    ->save("filepath");    

Also work with Eloquent Collections

$writer = ExcelWriter::create()
    ->setHeadings(["Lorem", "Ipsum", "Sit", "Amet"]);
    ->addContent(App\User::all())
    ->save("filepath");    

If you want to output the file to the browser:

$writer = ExcelWriter::create()
    ->setHeadings(["Lorem", "Ipsum", "Sit", "Amet"]);

$writer->addContent(["Row1", "Row1", "Row1", "Row1"]); 
    
$writer->addContent(["Row2", "Row2", "Row2", "Row2"])
    ->output("filename");    

Multi dimensional array

ExcelWriter::create()
    ->setHeadings(["Lorem", "Ipsum", "Sit", "Amet"]);
    ->addContent([
        ["Row1", "Row1", "Row1", "Row1"],
        ["Row2", "Row2", "Row2", "Row2"]
    ])
    ->save("filepath");

Default styles can be set for font weight, font size, font type and alignment

ExcelWriter::create(["bold" => true, "font" => "Arial", "size" => 20, "align" => "center"]);    

Styles can also be set for headings or specific row(s)

$writer = ExcelWriter::create();

$writer->setHeadings(
    ["Lorem", "Ipsum", "Sit", "Amet"],
    [
        "align" => "right",
        "bold"  => false,
        "size" => 15,
        "font" => "Arial"
    ]);
    
$writer->addContent(
    [
        ["Dolore", "Ipsum", "Amet", "Sit"],
        ["Dolore", "Ipsum", "Amet", "Sit"]
    ],
    [
        "align" => "right",
        "bold"  => false,
        "size" => 15,
        "font" => "Arial"
    ]
);

Sometimes you want some row spaces between the headings and the content rows:

$writer = ExcelWriter::create();

$writer->setHeadings(
    ["Lorem", "Ipsum", "Sit", "Amet"], [], 1);

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.