Added possiblity to add tables inside textbox

This commit is contained in:
Bas-Jan 't Jong 2014-05-10 14:04:15 +02:00
parent aa151c4010
commit 07b4ae2c0f
3 changed files with 16 additions and 3 deletions

View File

@ -53,4 +53,19 @@ class TextBox extends AbstractContainer
{
return $this->style;
}
/**
* Add table element
*
* @param mixed $style
* @return \PhpOffice\PhpWord\Element\Table
* @todo Merge with the same function on Footer
*/
public function addTable($style = null)
{
$table = new Table($this->getDocPart(), $this->getDocPartId(), $style);
$this->addElement($table);
return $table;
}
}

View File

@ -57,9 +57,7 @@ class TextBox extends Element
$margins = implode(', ', $tbxStyle->getInnerMargin());
$this->xmlWriter->writeAttribute('inset', $margins);
$this->xmlWriter->startElement('w:txbxContent');
$this->xmlWriter->startElement('w:p');
$this->parentWriter->writeContainerElements($this->xmlWriter, $this->element);
$this->xmlWriter->endElement(); // w:p
$this->xmlWriter->endElement(); // w:txbxContent
$this->xmlWriter->endElement(); // v: textbox
$styleWriter->writeW10Wrap();

View File

@ -110,7 +110,7 @@ abstract class AbstractPart
// Loop through elements
$elements = $container->getElements();
$withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false;
$withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false;
if (count($elements) > 0) {
foreach ($elements as $element) {
if ($element instanceof AbstractElement) {