| name | simple-spout |
| description | Use this skill when working with the Simple Spout package or when you need straightforward Excel import/export functionality. |
Simple Spout
SimpleSpout is a convenience wrapper around OpenSpout. It will read a spreadsheet and convert it to a PHP array, and can take a PHP array and convert it to an excel file. No formatting or fuss.
Example
<?php
namespace App\Whatever;
use Ohffs\SimpleSpout\ExcelSheet;
class Thing
{
public function something()
{
$data = (new ExcelSheet)->import('/tmp/spreadsheet.xlsx');
$data = (new ExcelSheet)->trimmedImport('/tmp/spreadsheet.xlsx');
$data = (new ExcelSheet)->importFirst('/tmp/spreadsheet.xlsx');
$data = (new ExcelSheet)->importSheet('/tmp/spreadsheet.xlsx', 3);
$data = (new ExcelSheet)->importActive('/tmp/spreadsheet.xlsx');
}
public function somethingElse()
{
$data = [
['smith', 'sarah-jane', 'companion'],
['baker', 'tom', 'doctor'],
];
$filename = (new ExcelSheet)->generate($data);
(new ExcelSheet)->generate($data, '/data/spreadsheet.xlsx');
}
}