Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PhpWord/Reader/Word2007/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ private function readCellStyle(XMLReader $xmlReader, DOMElement $domNode)
'gridSpan' => [self::READ_VALUE, 'w:gridSpan'],
'vMerge' => [self::READ_VALUE, 'w:vMerge', null, null, 'continue'],
'bgColor' => [self::READ_VALUE, 'w:shd', 'w:fill'],
'noWrap' => [self::READ_VALUE, 'w:noWrap', null, null, true],
];

return $this->readStyleDefs($xmlReader, $domNode, $styleDefs);
Expand Down
29 changes: 29 additions & 0 deletions src/PhpWord/Style/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ class Cell extends Border
*/
private $unit = TblWidth::TWIP;

/**
* Prevent text from wrapping in the cell.
*
* @var bool
*/
private $noWrap;

/**
* Get vertical align.
*
Expand Down Expand Up @@ -312,4 +319,26 @@ public function setUnit($value)

return $this;
}

/**
* Set noWrap.
*
* @param $value
*/
public function setNoWrap($value)
{
$this->noWrap = $this->setBoolVal($value, true);

return $this;
}

/**
* Get noWrap.
*
* @return bool
*/
public function getNoWrap()
{
return $this->noWrap;
}
}
4 changes: 4 additions & 0 deletions src/PhpWord/Writer/Word2007/Style/Cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function write(): void
$xmlWriter->writeElementIf(null !== $gridSpan, 'w:gridSpan', 'w:val', $gridSpan);
$xmlWriter->writeElementIf(null !== $vMerge, 'w:vMerge', 'w:val', $vMerge);

// noWrap
$noWrap = $style->getNoWrap();
$xmlWriter->writeElementIf(true === $noWrap, 'w:noWrap');

$xmlWriter->endElement(); // w:tcPr
}

Expand Down