anmoroz/xlsx-template-php

A library for templating of Excel Office documents. Supports MS Excel xlsx. Uses PHPSpreadsheet library.

dev-master 2019-10-16 12:36 UTC

This package is not auto-updated.

Last update: 2024-04-17 17:12:39 UTC


README

A library for templating of Excel Office documents. Supports MS Excel xlsx. Uses PhpSpreadsheet library.

Not only large documents.

An example

Input template

waybill_template

Some code

$templator = new Templator($templateFile, $outputDir, 'document.xlsx');


$settings = new Settings([
    'providerName' => 'ИП Сумкин Ф.Ф.',
    'clientName' => 'ООО "Рога и копыта"',
    'docNumber' => 5485,
    'docDate' => date('d.m.Y'),
    'totalProductAmount' => 4,
    'totalProductSum' => 2000,
]);


$loopData = new LoopData();
$loopData->setMap([
    'productName',
    'productArticle',
    'productUnit',
    'productAmount',
    'productPrice',
    'productSum',
]);
$loopData->setSource([
   ['Стол письменный', 'СП-234', 'шт.', 1, 1500, 1500],
   ['Чернильница', '75332', 'шт.', 2, 200, 400],
   ['Лампа настольная 12Вт', '6454', 'шт.', 1, 100, 100],
]);
$settings->addLoop(1, $loopData);


$templator->render($settings);
$templator->save();

Output document

document