tbcd/excel-utils

Easy way to create Excel worksheets, spreadsheets and files

1.1.1 2023-08-05 16:42 UTC

This package is auto-updated.

Last update: 2024-04-05 18:19:00 UTC


README

This library to easily create excel worksheets, spreadsheets and files.

Usage

  1. Inject the service from container if you have one or create it
private ExcelFileFactory $excelFileFactor;

public function __construct(ExcelFileFactory $excelFileFactory) 
{
    $this->excelFileFactory = $excelFileFactory;
}
$excelFileFactory = new ExcelFileFactory($spreadsheetFactory);
  1. Create the file with your data
$data = [
    [
        'column1' => 'row1',
        'column2' => 'row1',
        'column3' => 'row1'
    ],
    [
        'column1' => 'row2',
        'column2' => 'row2',
        'column3' => 'row2'
    ]
];

$filePath = $fileFactory->createFileWithData(new WorksheetData($data, 'my-sheet-name'), 'my_file.xlsx');
  1. Get then result below

alt text