Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions src/PhpWord/Style/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down
7 changes: 7 additions & 0 deletions src/PhpWord/Writer/Word2007/Style/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down