diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index a3d454f3aa..b7d778dc9c 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -121,6 +121,13 @@ class Table extends Border */ private $unit = self::WIDTH_AUTO; + /** + * Fixes the width of columns with long text without delimiters + * + * @var bool + */ + private $fixedColsWidth = true; + /** * Create new table style * @@ -582,6 +589,18 @@ public function setUnit($value = null) return $this; } + public function setFixedColsWidth($value = true) + { + $this->fixedColsWidth = $this->setBoolVal($value, $this->fixedColsWidth); + + return $this; + } + + public function isFixedColsWidth() + { + return $this->fixedColsWidth; + } + /** * Get table style only property by checking if it's a firstRow * diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php index 620e4fbf62..19d9a2738b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Table.php +++ b/src/PhpWord/Writer/Word2007/Style/Table.php @@ -76,6 +76,13 @@ private function writeStyle(XMLWriter $xmlWriter, TableStyle $style) $xmlWriter->endElement(); } + // Table fixed columns width + if ($style->isFixedColsWidth()) { + $xmlWriter->startElement('w:tblLayout'); + $xmlWriter->writeAttribute('w:type', 'fixed'); + $xmlWriter->endElement(); + } + $this->writeWidth($xmlWriter, $style->getWidth(), $style->getUnit()); $this->writeMargin($xmlWriter, $style); $this->writeBorder($xmlWriter, $style);