This repository has been archived by the owner on May 26, 2022. It is now read-only.
This repository has been archived by the owner on May 26, 2022. It is now read-only.
Default style with no text wrap is ignored #829
Open
Description
Automatic text wrapping due to the presence of new lines in a cell should only be applied if shouldWrapText
has not been set on the default style. Indeed the StyleManager
does check !$cellStyle->hasSetWrapText()
before applying automatic text wrapping, but the following sample shows the opposite behavior:
$defaultStyle = (new StyleBuilder())->setShouldWrapText(false)->build();
$writer = WriterEntityFactory::createXLSXWriter();
$writer->setDefaultRowStyle($defaultStyle)->openToFile('testNoWrap.xlsx');
$writer->addRow(WriterEntityFactory::createRowFromArray(["test\n"]));
$writer->close();
This seems to be because StyleMerger::mergeCellProperties
only calls setShouldWrapText
on the style to update if the $baseStyle
has shouldWrapText
true, whereas it probably should call it whenever hasSetWrapText
is true.
Current code:
if (!$style->hasSetWrapText() && $baseStyle->shouldWrapText()) {
$styleToUpdate->setShouldWrapText();
}
Possible fix:
if (!$style->hasSetWrapText() && $baseStyle->hasSetWrapText()) {
$styleToUpdate->setShouldWrapText($baseStyle->shouldWrapText());
}
Metadata
Metadata
Assignees
Labels
No labels
Activity