本文整理汇总了PHP中CreateDocx::addList方法的典型用法代码示例。如果您正苦于以下问题:PHP CreateDocx::addList方法的具体用法?PHP CreateDocx::addList怎么用?PHP CreateDocx::addList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreateDocx
的用法示例。
在下文中一共展示了CreateDocx::addList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateDocx
*/
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
//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>
示例2: exportCompleteReportDOC
/**
* Exports the complete report as a DOCX file
* @return boolean False on error
* @todo use unoconv
*/
public function exportCompleteReportDOC($data)
{
$_course = api_get_course_info();
$filename = 'gb_results_' . $_course['code'] . '_' . gmdate('YmdGis');
$filepath = api_get_path(SYS_ARCHIVE_PATH) . $filename;
//build the results
$inc = api_get_path(LIBRARY_PATH) . 'phpdocx/classes/CreateDocx.inc';
require_once api_get_path(LIBRARY_PATH) . 'phpdocx/classes/CreateDocx.inc';
$docx = new CreateDocx();
$paramsHeader = array('font' => 'Courrier', 'jc' => 'left', 'textWrap' => 5);
$docx->addHeader(get_lang('FlatView'), $paramsHeader);
$params = array('font' => 'Courrier', 'border' => 'single', 'border_sz' => 20);
$lines = 0;
$values[] = implode("\t", $data[0]);
foreach ($data[1] as $line) {
$values[] = implode("\t", $line);
$lines++;
}
//$data = array();
//$docx->addTable($data, $params);
$docx->addList($values, $params);
//$docx->addFooter('', $paramsHeader);
$paramsPage = array('orient' => 'landscape');
$docx->createDocx($filepath, $paramsPage);
//output the results
$data = file_get_contents($filepath . '.docx');
$len = strlen($data);
//header("Content-type: application/vnd.ms-word");
header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
//header('Content-Type: application/force-download');
header('Content-length: ' . $len);
header("Content-Disposition: attachment; filename=\"{$filename}.docx\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0,pre-check=0');
header('Pragma: public');
echo $data;
return true;
}
示例3: CreateDocx
<?php
//path to the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
//Custom options
$latinListOptions = array();
$latinListOptions[0]['type'] = 'lowerLetter';
$latinListOptions[0]['format'] = '%1.';
$latinListOptions[1]['type'] = 'lowerRoman';
$latinListOptions[1]['format'] = '%1.%2.';
//Create the list style with name: latin
$docx->createListStyle('latin', $latinListOptions);
//List items
$myList = array('item 1', array('subitem 1.1', 'subitem 1.2'), 'item 2');
//Insert custom list into the Word document
$docx->addList($myList, 'latin');
//Save the Word document
$docx->createDocx('example_createListStyle_1');
示例4: CreateDocx
<?php
//path to the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$itemList = array('Line 1', array('Line A', 'Line B', 'Line C'), 'Line 2', 'Line 3');
//we set the style type to 2: ordered list
$docx->addList($itemList, 2);
$docx->createDocx('example_addList_2');
示例5: CreateDocx
<?php
//path to the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$itemList = array('Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5');
//stablish some global run properties for each list item
$options = array('font' => 'Arial', 'italic' => true, 'fontSize' => 14, 'color' => 'b70000');
//we set the style type to 1: unordered list
$docx->addList($itemList, 1, $options);
$docx->createDocx('example_addList_4');
示例6: CreateDocx
<?php
//path to the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
//we prepare some formatted text for insertion in the list
$textData = new WordFragment($docx);
$text = array();
$text[] = array('text' => 'We insert some ');
$text[] = array('text' => 'bold text', 'b' => 'on');
$textData->addText($text);
//and also some simple HTML to illustrate the fexibility of the method
$htmlData = new WordFragment($docx);
$html = '<i>Some HTML code</i> with a <a href="http://www.phpdocx.com">link</a>';
$htmlData->embedHTML($html);
$itemList = array('In this example we use a custom list (val = 5) that comes bundled with the default PHPdocX template.', array($textData, 'Line B', 'Line C'), $htmlData, 'Line 3');
//we set the style type to 5: other predefined Word list style
$docx->addList($itemList, 5);
$docx->createDocx('example_addList_3');
示例7: CreateDocx
<?php
//path to the CreateDocx class within your PHPDocX installation
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$itemList = array('Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5');
//we set the style type to 1: unordered list
$docx->addList($itemList, 1);
$docx->createDocx('example_addList_1');
示例8: CreateDocx
<?php
/**
* Create a DOCX file. List example
*
* @category Phpdocx
* @package examples
* @subpackage easy
* @copyright Copyright (c) 2009-2011 Narcea Producciones Multimedia S.L.
* (http://www.2mdc.com)
* @license LGPL
* @version 2.0
* @link http://www.phpdocx.com
* @since File available since Release 2.0
*/
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$valuesList = array('Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5');
$paramsList = array('val' => 1);
$docx->addList($valuesList, $paramsList);
$docx->createDocx('example_list');