當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CreateDocx::addTable方法代碼示例

本文整理匯總了PHP中CreateDocx::addTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP CreateDocx::addTable方法的具體用法?PHP CreateDocx::addTable怎麽用?PHP CreateDocx::addTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CreateDocx的用法示例。


在下文中一共展示了CreateDocx::addTable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

//Importing header and footer from external .docx file
$docx->importHeadersAndFooters('../word_documents/templateHeaderAndFooter.docx');
$text = array();
$text[] = array('text' => 'I am going to write');
$text[] = array('text' => ' Hello World!', 'b' => 'single');
$text[] = array('text' => ' using bold characters.');
$docx->addText($text);
//We first prepare an item list element with more sophisticated formatting:
$paramsItem = array(array('text' => 'This is the text associated with the first item', 'b' => 'single', 'color' => 'b70000'), array('text' => ' now without bold'), array('text' => ' and blue', 'color' => '0000b7'));
$myItem = $docx->addElement('addText', $paramsItem);
//Let us now to add a nested unordered list
$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>
開發者ID:Ezyva2015,項目名稱:SMSF-Academy-Wordpress,代碼行數:31,代碼來源:example8.php

示例2: WordFragment

    Nam bibendum rutrum augue non pellentesque. Donec in mauris dui, 
    non sagittis dui. Phasellus quam leo, ultricies sit amet cursus nec, 
    elementum at est. Proin blandit volutpat odio ac dignissim. 
    In at lacus dui, sed scelerisque ante. Aliquam tempor, 
    metus sed malesuada vehicula, neque massa malesuada dolor, 
    vel semper massa ante eu nibh.');
//create a simple Word fragment to insert into the table
$textFragment = new WordFragment($docx);
$text = array();
$text[] = array('text' => 'Fit text and ');
$text[] = array('text' => 'Word fragment', 'bold' => true);
$textFragment->addText($text);
//stablish some row properties for the first row
$trProperties = array();
$trProperties[0] = array('minHeight' => 1000, 'tableHeader' => true);
$col_1_1 = array('rowspan' => 4, 'value' => '1_1', 'backgroundColor' => 'cccccc', 'borderColor' => 'b70000', 'border' => 'single', 'borderTopColor' => '0000FF', 'borderWidth' => 16, 'cellMargin' => 200);
$col_2_2 = array('rowspan' => 2, 'colspan' => 2, 'width' => 200, 'value' => $textFragment, 'backgroundColor' => 'ffff66', 'borderColor' => 'b70000', 'border' => 'single', 'cellMargin' => 200, 'fitText' => 'on', 'vAlign' => 'bottom');
$col_2_4 = array('rowspan' => 3, 'value' => 'Some rotated text', 'backgroundColor' => 'eeeeee', 'borderColor' => 'b70000', 'border' => 'single', 'borderWidth' => 16, 'textDirection' => 'tbRl');
//set teh global table properties
$options = array('columnWidths' => array(400, 1400, 400, 400, 400), 'border' => 'single', 'borderWidth' => 4, 'borderColor' => 'cccccc', 'borderSettings' => 'inside', 'float' => array('align' => 'right', 'textMargin_top' => 300, 'textMargin_right' => 400, 'textMargin_bottom' => 300, 'textMargin_left' => 400));
$values = array(array($col_1_1, '1_2', '1_3', '1_4', '1_5'), array($col_2_2, $col_2_4, '2_5'), array('3_5'), array('4_2', '4_3', '4_5'));
$docx->addTable($values, $options, $trProperties);
$docx->addText('In pretium neque vitae sem posuere volutpat. 
    Class aptent taciti sociosqu ad litora torquent per conubia nostra, 
    per inceptos himenaeos. Quisque eget ultricies ipsum. Cras vitae suscipit 
    erat. Nullam fermentum risus sed urna fermentum placerat laoreet arcu lobortis. 
    Integer nisl erat, vehicula eget posuere id, mollis fermentum mi. 
    Phasellus quis nulla orci. Suspendisse malesuada lectus et turpis facilisis 
    id imperdiet tellus luctus. In hac habitasse platea dictumst. Proin a mattis turpis. 
    Aliquam sit amet velit a lacus hendrerit bibendum. Mauris euismod dictum augue eget condimentum.');
$docx->createDocx('example_addTable_3');
開發者ID:Ezyva2015,項目名稱:SMSF-Academy-Wordpress,代碼行數:31,代碼來源:sample_3.php


注:本文中的CreateDocx::addTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。