2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Border;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|
|
|
|
2016-08-31 16:15:54 +00:00
|
|
|
require __DIR__ . '/Header.php';
|
|
|
|
|
|
|
|
// Create new Spreadsheet object
|
|
|
|
$helper->log('Create new Spreadsheet object');
|
2017-05-17 22:02:17 +00:00
|
|
|
$spreadsheet = new Spreadsheet();
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
// Set document properties
|
|
|
|
$helper->log('Set document properties');
|
|
|
|
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
|
|
|
->setLastModifiedBy('Maarten Balliauw')
|
|
|
|
->setTitle('Office 2007 XLSX Test Document')
|
|
|
|
->setSubject('Office 2007 XLSX Test Document')
|
|
|
|
->setDescription('Test document for Office 2007 XLSX, generated using PHP classes.')
|
|
|
|
->setKeywords('office 2007 openxml php')
|
|
|
|
->setCategory('Test result file');
|
|
|
|
|
|
|
|
// Add some data
|
|
|
|
$helper->log('Add some data');
|
|
|
|
$spreadsheet->setActiveSheetIndex(0);
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
$sharedStyle1 = new Style();
|
|
|
|
$sharedStyle2 = new Style();
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
$sharedStyle1->applyFromArray(
|
|
|
|
['fill' => [
|
2017-09-08 17:56:23 +00:00
|
|
|
'fillType' => Fill::FILL_SOLID,
|
2016-08-31 16:15:54 +00:00
|
|
|
'color' => ['argb' => 'FFCCFFCC'],
|
|
|
|
],
|
|
|
|
'borders' => [
|
2017-09-08 17:56:23 +00:00
|
|
|
'bottom' => ['borderStyle' => Border::BORDER_THIN],
|
|
|
|
'right' => ['borderStyle' => Border::BORDER_MEDIUM],
|
2016-08-31 16:15:54 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$sharedStyle2->applyFromArray(
|
|
|
|
['fill' => [
|
2017-09-08 17:56:23 +00:00
|
|
|
'fillType' => Fill::FILL_SOLID,
|
2016-08-31 16:15:54 +00:00
|
|
|
'color' => ['argb' => 'FFFFFF00'],
|
|
|
|
],
|
|
|
|
'borders' => [
|
2017-09-08 17:56:23 +00:00
|
|
|
'bottom' => ['borderStyle' => Border::BORDER_THIN],
|
|
|
|
'right' => ['borderStyle' => Border::BORDER_MEDIUM],
|
2016-08-31 16:15:54 +00:00
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$spreadsheet->getActiveSheet()->duplicateStyle($sharedStyle1, 'A1:T100');
|
|
|
|
$spreadsheet->getActiveSheet()->duplicateStyle($sharedStyle2, 'C5:R95');
|
|
|
|
|
|
|
|
// Save
|
|
|
|
$helper->write($spreadsheet, __FILE__);
|