outfile !== '') {
unlink($this->outfile);
$this->outfile = '';
}
}
public function testStyles(): void
{
$file = 'tests/data/Reader/XLSX/issue.4248.xlsx';
$reader = new XlsxReader();
$spreadsheet = $reader->load($file);
$writer = new XlsxWriter($spreadsheet);
$writer->setUseDiskCaching(true, sys_get_temp_dir());
$this->outfile = File::temporaryFilename();
$writer->save($this->outfile);
$spreadsheet->disconnectWorksheets();
$file = 'zip://';
$file .= $this->outfile;
$file .= '#xl/styles.xml';
$data = file_get_contents($file) ?: '';
$expected = ''
. ''
. '';
self::assertStringContainsString($expected, $data, 'neither fgColor nor bgColor');
$expected = ''
. ''
. ''
. '';
self::assertStringContainsString($expected, $data, 'bgColor but no fgColor');
$expected = ''
. '' // dxfId 1 - fill color for Oui
. ''
. ''
. ''
. ''
. ''
. '' // dxfId 2 - fill color for Non
. ''
. ''
. ''
. ''
. ''
. '';
self::assertStringContainsString($expected, $data, 'conditional fill styles');
$file = 'zip://';
$file .= $this->outfile;
$file .= '#xl/worksheets/sheet1.xml';
$data = file_get_contents($file) ?: '';
$expected = ''
. ''
. 'NOT(ISERROR(SEARCH("Oui",C16)))'
. ''
. '';
self::assertStringContainsString($expected, $data, 'first condition for D18');
$expected = ''
. ''
. 'NOT(ISERROR(SEARCH("Non",C16)))'
. ''
. '';
self::assertStringContainsString($expected, $data, 'second condition for D18');
}
public function testHtml(): void
{
$file = 'tests/data/Reader/XLSX/issue.4248.xlsx';
$reader = new XlsxReader();
$spreadsheet = $reader->load($file);
$writer = new HtmlWriter($spreadsheet);
$file = 'zip://';
$file .= $this->outfile;
$file .= '#xl/styles.xml';
$data = str_replace(["\r", "\n"], '', $writer->generateHtmlAll());
$expected = ' ' // Cell D18
. ' | | '
. ' | '
. ' Eligible | '
. ' Non | ';
self::assertStringContainsString($expected, $data, 'Cell D18 style');
$expected = ' td.style70, th.style70 { vertical-align:middle; text-align:center; border-bottom:1px solid #000000 !important; border-top:2px solid #000000 !important; border-left:2px solid #000000 !important; border-right:1px solid #000000 !important; font-weight:bold; color:#000000; font-family:\'Calibri\'; font-size:16pt; background-color:#BDD7EE }';
self::assertStringContainsString($expected, $data, 'background color');
$spreadsheet->disconnectWorksheets();
}
}