mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-25 16:08:19 +00:00
26 lines
821 B
PHP
26 lines
821 B
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter;
|
|
|
|
require __DIR__ . '/../Header.php';
|
|
|
|
$inputFileName = 'TableFormat.xlsx';
|
|
$inputFilePath = __DIR__ . '/../templates/' . $inputFileName;
|
|
|
|
$codePath = $helper->isCli() ? ('samples/templates/' . $inputFileName) : ('<code>' . 'samples/templates/' . $inputFileName . '</code>');
|
|
$helper->log('Read ' . $codePath);
|
|
$reader = IOFactory::createReader('Xlsx');
|
|
$reader->setReadDataOnly(false);
|
|
$spreadsheet = $reader->load($inputFilePath);
|
|
$helper->log('Enable table formatting output');
|
|
|
|
function writerCallback(HtmlWriter $writer): void
|
|
{
|
|
$writer->setPreCalculateFormulas(true);
|
|
$writer->setTableFormats(true);
|
|
}
|
|
|
|
// Save
|
|
$helper->write($spreadsheet, __FILE__, ['Html'], false, writerCallback: writerCallback(...));
|