//path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); $html = '<h1 style="color: #b70000">An embedHTML() example</h1>'; $html .= '<p>We draw a table with border and rawspans and colspans:</p>'; $html .= '<table border="1" style="border-collapse: collapse"> <tbody> <tr> <td style="background-color: yellow">1_1</td> <td rowspan="3" colspan="2">1_2</td> </tr> <tr> <td>Some random text.</td> </tr> <tr> <td> <ul> <li>One</li> <li>Two <b>and a half</b></li> </ul> </td> </tr> <tr> <td>3_2</td> <td>3_3</td> <td>3_3</td> </tr> </tbody> </table>'; $docx->embedHTML($html); $docx->createDocx('example_embedHTML_1');
$myList = array($myItem, 'item 2', array('subitem 2_1', 'subitem 2_2'), 'item 3', array('subitem 3_1', 'subitem 3_2', array('sub_subitem 3_2_1', 'sub_subitem 3_2_1')), 'item 4'); $docx->addList($myList, array('val' => 1)); $valuesTable = array(array('cell_1_1', 'cell_1_2', 'cell_1_3', 'cell_1_4'), array('cell_2_1', 'cell_2_2', 'cell_2_3', 'cell_2_4'), array('cell_3_1', 'cell_3_2', 'cell_3_3', 'cell_3_4')); $paramsTable = array('TBLSTYLEval' => 'MediumGrid3-accent5PHPDOCX'); $docx->addTable($valuesTable, $paramsTable); $myHTML = '<br /><p style="font-family: Calibri; font-size: 11pt">We include a table with rowspans and colspans using the embedHTML method.</p> <table style="font-family: Calibri; font-size: 11pt"> <tr> <td>header 1</td> <td>header 2</td> <td>header 3</td> <td>header 4</td> </tr> <tr> <td rowspan="2" colspan="2">cell_1_1</td> <td>cell_1_3</td> <td>cell_1_4</td> </tr> <tr> <td>cell_2_3</td> <td>cell_2_4</td> </tr> <tr> <td>cell_3_1</td> <td>cell_3_2</td> <td>cell_3_3</td> <td>cell_3_4</td> </tr> </table>'; $docx->embedHTML($myHTML, array('tableStyle' => 'MediumGrid3-accent5PHPDOCX')); $docx->createDocx('../word_documents/example_table_style_HTML');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); $docx->embedHTML('<h1 style="color: #b70000">The Wikipedia Article on the Periodic Table</h1>'); $html = file_get_contents('http://en.wikipedia.org/wiki/Periodic_table'); $options = array('parseDivsAsPs' => true, 'baseURL' => 'http://en.wikipedia.org/', 'downloadImages' => true, 'filter' => '#bodyContent'); $docx->embedHTML($html, $options); $docx->modifyPageLayout('A3-landscape'); $docx->createDocx('example_embedHTML_2');