PHP code example of alhimik1986 / php-excel-templator
1. Go to this page and download the library: Download alhimik1986/php-excel-templator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alhimik1986 / php-excel-templator example snippets
$events = [
PhpExcelTemplator::BEFORE_INSERT_PARAMS => function(Worksheet $sheet, array $templateVarsArr) {
// fires before inserting values into template variables
},
PhpExcelTemplator::AFTER_INSERT_PARAMS => function(Worksheet $sheet, array $templateVarsArr) {
// fires after inserting values into template variables.
// It is used if you want to insert valuesinto a spreadsheet after columns and rows have been created.
// For example, when inserting an array of images.
// If you insert images using $callbacks, then the images can shift to the right due to the fact that on the next line the template variable can create additional columns.
// See an example: samples/10_images
},
PhpExcelTemplator::BEFORE_SAVE => function(Spreadsheet $spreadsheet, IWriter $writer) {
// fires before saving to a file. It is used when you need to modify the $writer or $spreadsheet object before saving, for example, $writer->setPreCalculateFormulas(false);
},
];
$callbacks = [];
$templateFile = './template.xlsx';
$fileName = './exported_file.xlsx';
$params = [
// ...
];
PhpExcelTemplator::saveToFile($templateFile, $fileName, $params, $callbacks, $events);
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.