-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
This is:
- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
Consistency among TextElement
styles of the same RichText
value after applying a cell style. Desired behavior would be one of the following:
- Overwrite any applicable
TextElement
andRun
styles. - Overwrite any applicable
TextElement
styles, and ignore allRun
styles. - Ignore all
TextElement
andRun
styles.
What is the current behavior?
Inconsistency among TextElement
styles of the same RichText
value after applying a cell style. Current behavior is that setting a cell style only overwrites any applicable TextElement
styles found before a Run
style; any TextElement
styles found after a Run
style are ignored.
What are the steps to reproduce?
<?php
require_once 'vendor/autoload.php';
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
use \PhpOffice\PhpSpreadsheet\RichText\RichText;
use \PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$workbook = new Spreadsheet();
$rtf = new RichText();
/* This segment will receive applied cell styles. */
$rtf->createText('~Cell Style~');
/* This segment ignore applied cell styles. */
$rtf->createTextRun('~RTF Style~')->getFont()->setItalic(true);
/* This segment will also ignore applied cell styles. */
$rtf->createText('~No Style~');
$sheet = $workbook->getSheet(0);
$sheet->getCell('A1')->setValue($rtf);
$sheet->getStyle('A1')->getFont()->setBold(true);
(new Xlsx($workbook))->save('output.xlsx');
$workbook->disconnectWorksheets();
unset($workbook);
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet [1.9]
PHP [7.1.27]
Metadata
Metadata
Assignees
Labels
No labels