2017 © Pedro Peláez
 

library f3-sheet

Some Excel and CSV utilities for PHP Fat-Free Framework

image

ikkez/f3-sheet

Some Excel and CSV utilities for PHP Fat-Free Framework

  • Friday, August 11, 2017
  • by ikkez
  • Repository
  • 1 Watchers
  • 4 Stars
  • 90 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 55 % Grown

The README.md

Sheet

Some Excel and CSV utilities for PHP Fat-Free Framework., (*1)

Example from Array of Data

$excel = \Sheet::instance();

// data array
$rows = [ 
    [
        "name" => "rose",
        "color" => "red",
        "num" => 15
    ],
    [
        "name" => "daisy",
        "color" => "yellow",
        "num" => 25,
    ],
    [
        "name" => "orchid",
        "color" => "purple",
        "num" => 7
    ]
];
// header array to rename the field labels and sort/reorder the data array 
$headers = ['name'=>'Name', 'num'=>'Number', 'color'=>'Flower Color'];

$excel->renderXLS($rows,$headers,"flowers.xls");

In case your data array is not keyed, you can use the applyHeader method to transform the array:, (*2)

$rows = [ 
    [
        "rose",
        "red",
        15
    ],
    [
        "daisy",
        "yellow",
        25,
    ],
    [
        "orchid",
        "purple",
        7
    ]
];
$rows = \Sheet::instance()->applyHeader($rows,['name','color','num']);

Example from Fat Free Mapper Object

//Setup mapper
$items = new \DB\SQL\Mapper($db,'mytable');

//Load all items and map to associative array
$all = array_map(array($items,'cast'),$items->find());

$csv = \Sheet::instance();
$csv->renderCSV($all, $items->fields(), "items.csv");

Notice

The generated XLS can have problems in older versions of MS Office (Excel) with number-formatted fields not being recognized as such (displayed as text instead) and text fields, that contain line breaks can also leads to problems there (missing text)., (*3)

Nevertheless, these problems do not appear when opened with LibreOffice or OpenOffice or rendered as csv with renderCSV instead and then imported to excel., (*4)

License

You are allowed to use this plugin under the terms of the GNU General Public License version 3 or later., (*5)

Copyright (C) 2017 Christian Knuth [ikkez], (*6)

The Versions

11/08 2017

dev-master

9999999-dev https://github.com/ikkez/f3-sheet

Some Excel and CSV utilities for PHP Fat-Free Framework

  Sources   Download

GPL-3.0

f3 csv excel xls export fatfree

11/08 2017

v0.4.1

0.4.1.0 https://github.com/ikkez/f3-sheet

Some Excel and CSV utilities for PHP Fat-Free Framework

  Sources   Download

GPL-3.0

f3 csv excel xls export fatfree