mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-02 21:48:11 +00:00
ffeaa42583
Xlsx conditional styles cannot be used to change alignment, nor font family, nor font size. Conditional::getStyle currently allocates a new style as an unconditional style; it is changed to do so a conditional ctyle. Border should not be conditionally merged if borderStyle is OMIT. Inline Css was generating `class="gridlines gridlinesp"` for all cells. It is changed to use the worksheet settings to decide which classes to use.
63 lines
2.5 KiB
PHP
63 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Writer\Html;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\Style\Border;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Html;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class NoTitleTest extends TestCase
|
|
{
|
|
public function testNoTitle(): void
|
|
{
|
|
$file = 'tests/data/Reader/XLSX/blankcell.xlsx';
|
|
$reader = new XlsxReader();
|
|
$spreadsheet = $reader->load($file);
|
|
self::assertSame('', $spreadsheet->getProperties()->getTitle());
|
|
|
|
$writer = new Html($spreadsheet);
|
|
$writer->setUseInlineCss(true);
|
|
$html = $writer->generateHTMLAll();
|
|
self::assertStringContainsString('<title>Sheet1</title>', $html);
|
|
self::assertStringContainsString('<td class="gridlines" style="vertical-align:bottom; color:#000000; font-family:\'Calibri\'; font-size:11pt; text-align:left; width:42pt">C1</td>', $html);
|
|
$writer->setUseInlineCss(false);
|
|
$html = $writer->generateHTMLAll();
|
|
self::assertStringContainsString('<td class="column2 style0 s">C1</td>', $html);
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
|
|
public function testHideSomeGridlines(): void
|
|
{
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->fromArray(
|
|
[
|
|
[1, 2, 3, 4, 5, 6],
|
|
[7, 8, 9, 10, 11, 12],
|
|
[17, 18, 19, 20, 21, 22],
|
|
[27, 28, 29, 30, 31, 32],
|
|
[37, 38, 39, 40, 41, 42],
|
|
]
|
|
);
|
|
$sheet->getStyle('B2:D4')->getBorders()->applyFromArray(
|
|
[
|
|
'allBorders' => [
|
|
'borderStyle' => Border::BORDER_NONE,
|
|
'color' => ['rgb' => '808080'],
|
|
],
|
|
],
|
|
);
|
|
|
|
$writer = new Html($spreadsheet);
|
|
$writer->setUseInlineCss(true);
|
|
$html = $writer->generateHTMLAll();
|
|
self::assertStringContainsString('<td class="gridlines" style="vertical-align:bottom; color:#000000; font-family:\'Calibri\'; font-size:11pt; text-align:right; width:42pt">7</td>', $html);
|
|
self::assertStringContainsString('<td class="gridlines" style="vertical-align:bottom; border-bottom:none #808080; border-top:none #808080; border-left:none #808080; border-right:none #808080; color:#000000; font-family:\'Calibri\'; font-size:11pt; text-align:right; width:42pt">19</td>', $html);
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|