mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-17 22:23:02 +00:00
39df9c3bcc
* Fix Some Pdf Problems Fix #1747. No support for text rotation in Pdf. That issue actually has a decent workaround, but PhpSpreadsheet should handle it on its own. Mpdf requires the proprietary text-rotate css attribute; Html and Dompdf will use the CSS3 attribute transform:rotate. Fix #1713. Some paper-size values in PhpSpreadsheet are strings, some are 2-element float arrays. Dompdf accepts strings or 4-element float arrays, where the first 2 elements are always 0. Convert the PhpSpreadsheet array accordingly before passing it to Dompdf. Some tests had been disabled when Dompdf and Tcpdf were slow to achieve PHP8 compliance. They achieved it some time ago. Re-enable the tests. * Remove Tcpdf From One Test No problem with the other tests I added it in for.
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
require __DIR__ . '/../Header.php';
|
|
|
|
// Read from Xlsx (.xlsx) template
|
|
$helper->log('Load Xlsx template file');
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
|
|
|
|
// at this point, we could do some manipulations with the template, but we skip this step
|
|
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
|
|
|
|
// Export to PDF (.pdf)
|
|
$helper->log('Write to PDF format');
|
|
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
|
|
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
|
|
|
// Remove first two rows with field headers before exporting to CSV
|
|
$helper->log('Removing first two heading rows for CSV export');
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
$worksheet->removeRow(1, 2);
|
|
|
|
// Export to CSV (.csv)
|
|
$helper->log('Write to CSV format');
|
|
/** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writer */
|
|
$writer = IOFactory::createWriter($spreadsheet, 'Csv');
|
|
$filename = $helper->getFilename(__FILE__, 'csv');
|
|
$callStartTime = microtime(true);
|
|
$writer->save($filename);
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
// Export to CSV with BOM (.csv)
|
|
$filename = str_replace('.csv', '-bom.csv', $filename);
|
|
$helper->log('Write to CSV format (with BOM)');
|
|
$writer->setUseBOM(true);
|
|
$callStartTime = microtime(true);
|
|
$writer->save($filename);
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|