Skip to content

::addHtml() into a cell #1411

@tom-lp-at

Description

@tom-lp-at

This is:

Expected Behavior

write the HTML-Text into the Cell with the correct formatting

Current Behavior

the HTML-Text comes with a standard-layout. The Cell`s before and after have correct formating

Failure Information

The cells are formatted with "size"=>6. The Fontformat can assign via ->addText(), but not with ::addHtml().
I try the code from ticket #417 - but no success

How to Reproduce

<?php
        $phpWord = new \PhpOffice\PhpWord\PhpWord();
        $section = $phpWord->addSection();

        $Aend_TableStyleName = 'AenderungTable';
        $Aend_TableStyle = array('borderSize' => 1, 'borderColor' => '9bc21c', 'cellMargin' => 0, 'alignment' => \PhpOffice\PhpWord\SimpleType\JcTable::CENTER);
        $Aend_TableFirstRowStyle = array('borderBottomSize' => 0, 'borderBottomColor' => '0000ff', 'bgColor' => '9bc21c','cellMargin' => 0, 'spaceBefore' => 80);
        $Aend_TableCellStyle = array('valign' => 'center','cellMargin' => 0,'size' => 6);
        $Aend_TableFontStyle = array('bold' => true,'bgcolor' => '9bc21c','spaceAfter' => 0,'cellMargin' => 0,'italic' => true,'size' => 6);
        $phpWord->addTableStyle($Aend_TableStyleName, $Aend_TableStyle, $Aend_TableFirstRowStyle);

        $table = $section->addTable($Aend_TableStyleName);
	$table->addRow(90);
	$table->addCell(800, $TableCellStyleVoll)->addText(LP_say('Datum'), $TableFontStyle);
	$table->addCell(800, $TableCellStyleVoll)->addText(LP_say('Tabelle'), $TableFontStyle);
	$table->addCell(800, $TableCellStyleVoll)->addText(LP_say('Feld'), $TableFontStyle);
	$table->addCell(2800, $TableCellStyleVoll)->addText(LP_say('Inhalt'), $TableFontStyle);
	$table->addCell(500, $TableCellStyleVoll)->addText(LP_say('von'), $TableFontStyle);
	$table->addCell(2800, $TableCellStyleVoll)->addText(LP_say('Grund'), $TableFontStyle);
		
	foreach($history_punkt['historie'] as $historie) {
		$table->addRow(null,$Aend_TableFontStyle);
		$table->addCell(800)->addText($historie['datum'],$Aend_TableCellStyle);
		$table->addCell(800)->addText($historie['tabelle'],$Aend_TableCellStyle);
		$table->addCell(800)->addText($historie['feldname'],$Aend_TableCellStyle);
		$zelle = $table->addCell(2800);
		\PhpOffice\PhpWord\Shared\Html::addHtml($zelle, "<tbody style=\"font-size:6;\">".$historie['wert']."</tbody>",false,false,null);
		$table->addCell(500)->addText($historie['wer'],$Aend_TableCellStyle);
		$table->addCell(2800)->addText($historie['grund'],$Aend_TableCellStyle);
	}

Context

  • Fedora 27 Workstation
  • PHP version: 7.1.18
  • PHPWord version: dev-master

What did i miss ? Iss there a Workaround (i tryd allready to add the HTML into a textrun, but can`t assign the textrun to the cell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions