Formating a text in a table cell with PHPWord e.g. bold, font, size e.t.c

Posted by alphy on Stack Overflow See other posts from Stack Overflow or by alphy
Published on 2013-08-02T15:33:11Z Indexed on 2013/08/02 15:36 UTC
Read the original article Hit count: 327

Filed under:
|

I have the code snippet below

  //create a new word document

    $word= new PHPWord();

    //create potrait orientation
    $section=$word->createSection();   


    $table = $section->addTable();
    $word->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16));
    //header row
    $table->addRow(400, array('bgColor'=>'dbdbdb'));
    $table->addCell(2000, array('bgColor'=>'dbdbdb'))->addText('Cell 1','rStyle');
    $table->addCell(3500, array('bgColor'=>'dbdbdb'))->addText('Cell 1');
    $table->addCell(1500, array('bgColor'=>'dbdbdb'))->addText('Cell 1','rStyle');
    $table->addCell(2000, array('bgColor'=>'dbdbdb'))->addText('Cell 1');       

    // Save File
    $objWriter = PHPWord_IOFactory::createWriter($word, 'Word2007');
    $objWriter->save('Text.docx');
    echo 'Text.docx created successfully';
}

How can i add text formatting to a cell value to bold, italic, font-size etc, I have tried as shown above but it does not work

© Stack Overflow or respective owner

Related posts about php

Related posts about phpword