mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-23 10:32:48 +00:00
29c0162e2a
* Let Phpstan Run on Samples Phpstan currently analyzes all source and test members. We already run phpcs and php-cs-fixer on samples as well. I would expect that samples are often used as templates for code in userland; it behooves us to be at least as careful with those members as for the others which are already being analyzed. Aside from 1300+ messages `Variable $helper might not be defined.`, which will be suppressed in phpstan.neon.dist, there are really only a few changes needed for sample members, so that part of the code base was already in good shape, and is now even better. No annotations were needed. * Scrutinizer 2 out of 3 1 false positive, now suppressed; fix other 2. * Remove Dead Code * Very Minor Changes * Add infra
32 lines
991 B
PHP
32 lines
991 B
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf2;
|
|
|
|
require __DIR__ . '/../Header.php';
|
|
require_once __DIR__ . '/Mpdf2.php';
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
$helper->log('Show print grid lines');
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->setPrintGridLines(true);
|
|
|
|
$sheet->getCell('A1')->setValue('First Cell');
|
|
$sheet->getCell('A2')->setValue('Second Cell');
|
|
$sheet->getCell('B1')->setValue('Third Cell');
|
|
$sheet->getCell('B2')->setValue('Fourth Cell');
|
|
|
|
$helper->log('Set style to unusual font');
|
|
$sheet->getStyle('A1:B2')->getFont()->setName('Shadows Into Light');
|
|
|
|
$helper->log('Write to Mpdf');
|
|
$writer = new Mpdf2($spreadsheet);
|
|
$filename = $helper->getFileName(__FILE__, 'pdf');
|
|
$writer->save($filename);
|
|
$helper->log("Saved $filename");
|
|
if (PHP_SAPI !== 'cli') {
|
|
echo '<a href="/download.php?type=pdf&name=' . basename($filename) . '">Download ' . basename($filename) . '</a><br />';
|
|
}
|
|
$spreadsheet->disconnectWorksheets();
|