mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-18 05:57:33 +00:00
668d3b5fde
* All Readers - Allow or Forbid Fetching of External Images Release390 Add to all readers the option to allow or forbid fetching external images. This is unconditionally allowed now. The default will be set to "allow", so no code changes are necessary. However, we are giving consideration to changing the default. * Update Changelog
35 lines
867 B
PHP
35 lines
867 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Html;
|
|
use PhpOffice\PhpSpreadsheet\Shared\File;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
class HtmlHelper
|
|
{
|
|
public static function createHtml(string $html): string
|
|
{
|
|
$filename = File::temporaryFilename();
|
|
file_put_contents($filename, $html);
|
|
|
|
return $filename;
|
|
}
|
|
|
|
public static function loadHtmlIntoSpreadsheet(string $filename, bool $unlink = false, ?bool $allowExternalImages = null): Spreadsheet
|
|
{
|
|
$html = new Html();
|
|
if ($allowExternalImages !== null) {
|
|
$html->setAllowExternalImages($allowExternalImages);
|
|
}
|
|
$spreadsheet = $html->load($filename);
|
|
if ($unlink) {
|
|
unlink($filename);
|
|
}
|
|
|
|
return $spreadsheet;
|
|
}
|
|
}
|