本文整理汇总了PHP中PHPWord::addTableStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord::addTableStyle方法的具体用法?PHP PHPWord::addTableStyle怎么用?PHP PHPWord::addTableStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWord
的用法示例。
在下文中一共展示了PHPWord::addTableStyle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test()
{
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once APPPATH . '/libraries/PHPWord.php';
//$this->load->library('PHPWord');
// Create a new PHPWord Object
$PHPWord = new PHPWord();
//$PHPWord = $this->phpword;
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();
// After creating a section, you can append elements:
$section->addText('Hello world!');
// You can directly style your text by giving the addText function an array:
$section->addText('Hello world! I am formatted.', array('name' => 'Tahoma', 'size' => 16, 'bold' => true));
// If you often need the same style again you can create a user defined style to the word document
// and give the addText function the name of the style:
$PHPWord->addFontStyle('myOwnStyle', array('name' => 'Verdana', 'size' => 14, 'color' => '1B2232'));
$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle');
// You can also putthe appended element to local object an call functions like this:
$myTextElement = $section->addText('Hello World!');
//$myTextElement->setBold();
//$myTextElement->setName('Verdana');
//$myTextElement->setSize(22);
$styleTable = array('borderColor' => '006699', 'borderSize' => 6, 'cellMargin' => 50);
$styleFirstRow = array('bgColor' => '66BBFF');
$PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);
$table = $section->addTable('myTable');
$table->addRow();
$cell = $table->addCell(2000);
$cell->addText('Cell 1');
$cell = $table->addCell(2000);
$cell->addText('Cell 2');
// $cell = $table->addCell(2000);
//$cell->addText('Cell 3');
// Add image elements
$section->addImage(APPPATH . '/images/side/jqxs-l.JPG');
$section->addTextBreak(1);
//$section->addImage(APPPATH.'/images/side/jqxs-l.JPG', array('width'=>210, 'height'=>210, 'align'=>'center'));
//$section->addTextBreak(1);
//$section->addImage(APPPATH.'/images/side/jqxs-l.jpg', array('width'=>100, 'height'=>100, 'align'=>'right'));
// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('helloWorld.docx');
exit;
//download
/*
$filename='just_some_random_name.docx'; //save our document as this file name
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('php://output');
*/
//force download
// $this->load->helper('download');
// $data = file_get_contents("helloWorld.docx"); // Read the file's contents
// $name = 'helloWorld.docx';
// force_download($name, $data);
}
示例2: generateResume
public function generateResume($id = NULL)
{
//Проверяем, зарегестрированн ли пользователь и его роль
if (isset($this->session->userdata['id'])) {
$user = Doctrine::getTable('User')->findOneBy('id', $this->session->userdata['id']);
if ($user->getRole() == 'applicant') {
echo json_encode(array('status' => false, 'msg' => 'Скачивать резюме могут только работодатели и агентства!'));
exit;
}
} else {
echo json_encode(array('status' => false, 'msg' => 'Скачивать резюме могут только зарегестрированные пользователи!'));
exit;
}
if (empty($id)) {
echo json_encode(array('status' => false));
exit;
}
$resume = Doctrine::getTable('Resume')->findOneBy('id', $id);
if (empty($resume)) {
echo json_encode(array('status' => false));
exit;
}
//Папка для хранения файлов
$path = str_replace('system/', '', BASEPATH) . 'downloads/resumes/';
//Создаем ее, если она была созданна ранее
if (!file_exists($path)) {
mkdir($path, 0, true);
}
//Имя файла с резюме
$file_name = 'resume_' . $id . '.docx';
//Если такой файл уже есть, то проверяем дату его создания
if (file_exists($path . $file_name)) {
if ($resume->modification_date != NULL and $resume->modification_date >= date('Y-m-d H:i:s', filectime($path . $file_name))) {
echo json_encode(array('status' => true, 'url' => site_url() . 'downloads/resumes/' . $file_name));
exit;
} else {
unlink($path . $file_name);
}
}
$this->load->library('PHPWord');
$word = new PHPWord();
$section = $word->createSection();
$section->addText('Резюме от: ' . date('Y.m.d', $resume->getPlacementDate()), array('name' => 'Verdana', 'color' => '006699'));
$section->addText($resume->formatName('s n p'), array('name' => 'Verdana', 'bold' => true, 'size' => 20));
$section->addImage($resume->getRealImagePath(), array('align' => 'left'));
$section->addTextBreak();
$bold = array('bold' => true);
$grey = array('bgColor' => 'dcdcdc', 'valign' => 'center');
$center = array('valign' => 'center');
$styleTable = array('borderSize' => 4, 'borderColor' => 'dcdcdc');
$word->addTableStyle('myOwnTableStyle', $styleTable);
$table = $section->addTable('myOwnTableStyle');
$data = array('Возраст:' => $resume->getResumeAuthorAge(), 'Пол:' => $resume->gender->getDescription(), 'Семейное положение:' => $resume->family_state->getValue(), 'Наличие детей:' => $resume->getChilds(), 'Город проживания:' => $resume->getCity(), 'Район проживания:' => $resume->getArea(), 'Национальность:' => $resume->getNationality(), 'E-mail:' => $resume->getContactEmail(), 'Контактный телефон:' => $resume->getContactPhone());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
$section->addTextBreak();
//Желаемая должность
$section->addText(trim($resume->getDesiredPosition()) == '' ? 'Точная информация о интересующей должности не указанна' : $resume->getDesiredPosition(), array('name' => 'Verdana', 'bold' => true, 'size' => 16));
//Дополнительно рассматриваемые должности
if (count($resume->getPositions()) > 0) {
$section->addText('Также рассматриваются:', array('name' => 'Verdana', 'bold' => true, 'size' => 12));
foreach ($resume->getPositions() as $position_id) {
$position = Doctrine::getTable('Position')->findOneBy('id', $position_id);
$section->addText($position->getName());
}
}
$table = $section->addTable('myOwnTableStyle');
$table->addRow();
$table->addCell(3000, $grey)->addText("Квалификация:", $bold);
$cell = $table->addCell('3000', $center);
foreach ($resume->getQualificationForWord() as $item) {
$cell->addText($item);
}
$data = array('Описание опыта работы:' => $resume->getExperienceDescription(), 'Период опыта работы:' => $resume->experience->getValue(), 'Наличие рекомендаций:' => $resume->getGuidanceAvailability());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
$section->addTextBreak();
$section->addText('Образование', array('name' => 'Verdana', 'color' => '006699', 'bold' => true, 'size' => 16));
$table = $section->addTable('myOwnTableStyle');
$table->addRow();
$table->addCell(3000, $grey)->addText("Образование:", $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($resume->education->getValue(), array(), array('spaceAfter' => 0));
$table->addRow();
$table->addCell(3000, $grey)->addText("Специальность:", $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($resume->getSpeciality(), array(), array('spaceAfter' => 0));
$section->addTextBreak();
$section->addText('Пожелания к работе', array('name' => 'Verdana', 'color' => '006699', 'bold' => true, 'size' => 16));
$table = $section->addTable('myOwnTableStyle');
$data = array('Регион работы:' => $resume->getWorkRegion()->getValue(), 'Работа с проживанием в семье:' => (int) $resume->getHomestay() == 1 ? 'Да' : 'Нет', 'Вид занятости:' => $resume->getOperatingSchedulesText(), 'График работы:' => $resume->getWorkTimetable(), 'Заработная плата:' => $resume->getPaymentDetails());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
//.........这里部分代码省略.........
示例3: PHPWord
<?php
require APPPATH . 'third_party/PHPWord/PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$PHPWord->addTableStyle('schedule_billdoc', array('borderSize' => 1, 'borderColor' => '333', 'cellMargin' => 100));
$table = $section->addTable('schedule_billdoc');
foreach ($document_catalog as $doctype) {
$table->addRow();
$table->addCell(1500)->addText($doctype);
$table->addCell(8000);
}
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = $_SESSION['username'] . $this->date->now . '.docx';
$path = iconv('utf-8', 'gbk', 'temp/' . $filename);
$objWriter->save($path);
document_exportHead($filename);
readfile($path);
unlink($path);
exit;
示例4: PHPWord
require_once '../PHPWord.php';
// New Word Document
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Define table style arrays
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
// Define cell style arrays
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
// Define font style for first row
$fontStyle = array('bold' => true, 'align' => 'center');
// Add table style
$PHPWord->addTableStyle('myOwnTableStyle', $styleTable, $styleFirstRow);
// Add table
$table = $section->addTable('myOwnTableStyle');
// Add row
$table->addRow(900);
// Add cells
$table->addCell(2000, $styleCell)->addText('Row 1', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 2', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 3', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 4', $fontStyle);
$table->addCell(500, $styleCellBTLR)->addText('Row 5', $fontStyle);
// Add more rows / cells
for ($i = 1; $i <= 10; $i++) {
$table->addRow();
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
示例5: PHPWord
// New Word Document
$PHPWord = new PHPWord();
$properties = $PHPWord->getProperties();
$properties->setCreator('Kelluwen');
$properties->setCompany('Kelluwen');
$_estilo_titulo = array('name' => 'Verdana', 'color' => '000000');
$_estilo_titulo_form_diseno = array('bold' => true);
$_estilo_titulo_actividad = array('bold' => true);
// New portrait section
$section = $PHPWord->createSection();
$sectionStyle = $section->getSettings();
// Add header
$header = $section->createHeader();
$styleTable = array('borderColor' => '006699', 'borderSize' => 2);
$styleFirstRow = array('bgColor' => '66BBFF');
$PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);
$table = $header->addTable();
$table->addRow();
//$table->addCell(1510)->addImage('./../img/logo.gif', array('width'=>151, 'height'=>43, 'align'=>'left'));
replaceHtml($table->addCell(1510), '<img src="./../img/logo.jpg">');
// $table->addCell(4500)->addText('Proyecto FONDEF D08i-1074', array('size'=>12), array('align'=>'right'));
// $table->addCell(4500)->addText('www.kelluwen.cl', array('size'=>10), array('align'=>'right'));
$table->addCell(2500)->addText('');
$text = "<p><b><" . $lang_crear_diseno_word_proyecto . "</b></p><p>" . $lang_crear_diseno_url_kelluwen . "</p>";
replaceHtml($table->addCell(3700), $text, array('align' => 'right', 'border' => false, 'spaceAfter' => 10));
$PHPWord->addFontStyle('tamano_titulo', array('bold' => true, 'italic' => false, 'size' => 12));
$PHPWord->addParagraphStyle('parrafo_titulo', array('align' => 'center'));
$section->addTextBreak(1);
$section->addText($lang_crear_diseno_word_estructura . ": " . $fcd_nombre, 'tamano_titulo', 'pStyle');
// $section->addTextBreak(1);
/*TABLA CON EL RESUMEN DE LAS ACTIVIDADES*/
示例6: array
$valueFontStyle = array();
//
$cellValueMergeStartStyle = array_merge($valueFontStyle, array('cellMerge' => 'restart'));
$cellTitleMergeStartStyle = array_merge($titleFontStyle, array('cellMerge' => 'restart'));
$rowTitleMergeStartStyle = array_merge($titleFontStyle, array('rowMerge' => 'restart'));
define('CELL_LABEL_TITLE_WIDTH', 3500);
// 标题
$PHPWord->addFontStyle('headTitleFontStyle', array('bold' => true, 'size' => 16));
$PHPWord->addParagraphStyle('headTitlePStyle', array('align' => 'center', 'spaceAfter' => 100));
$section->addText('澳 通 人 才 网 登 记 表', 'headTitleFontStyle', 'headTitlePStyle');
// 备注
$PHPWord->addFontStyle('markFontStyle', array('size' => 12));
$PHPWord->addParagraphStyle('markPStyle', array('align' => 'right', 'spaceAfter' => 100));
$section->addText('填表日期: 年 月 日', 'markFontStyle', 'markPStyle');
// 添加表格的样式
$PHPWord->addTableStyle('myOwnTableStyle', array('borderSize' => 6, 'cellMargin' => 80), array());
// 添加一个表格
$table = $section->addTable('myOwnTableStyle');
// 第一行
$table->addRow();
// Add cells
$table->addCell(CELL_LABEL_TITLE_WIDTH, $styleCell)->addText('姓名', $titleFontStyle);
$table->addCell(2000, $styleCell)->addText('曾繁斌', $valueFontStyle);
$table->addCell(CELL_LABEL_TITLE_WIDTH, $styleCell)->addText('性别', $titleFontStyle);
$table->addCell(2000, $styleCell)->addText('男', $valueFontStyle);
$table->addCell(CELL_LABEL_TITLE_WIDTH, $styleCell)->addText('出生年月', $titleFontStyle);
$table->addCell(2000, $styleCell)->addText('1991-11', $valueFontStyle);
$table->addCell(CELL_LABEL_TITLE_WIDTH, $styleCell)->addText('民族', $titleFontStyle);
$table->addCell(2000, $styleCell)->addText('汉族', $valueFontStyle);
$table->addCell(2000, array('rowMerge' => 'restart'))->addImage('_earth.JPG', array('width' => 100, 'height' => 100, 'align' => 'center'));
// 第二行
示例7: makePaper
public static function makePaper($questions, $subCode, $date, $time, $session, $internal, $sec)
{
$sem = $questions[1][1]->subject()->first()->sem;
$subject = $questions[1][1]->subject()->first()->name;
// Create a new PHPWord Object
$PHPWord = new PHPWord();
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();
$PHPWord->addFontStyle('myNoteStyle', array('name' => 'Calibri', 'size' => 11, 'bold' => true, 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE));
$PHPWord->addFontStyle('myOwnStyle', array('name' => 'Calibri', 'size' => 11, 'bold' => true));
$PHPWord->addParagraphStyle('myGapTStyle', array('name' => 'Calibri', 'size' => 5, 'bold' => true));
$PHPWord->addParagraphStyle('myGapPStyle', array('spaceAfter' => 0));
$PHPWord->addParagraphStyle('myHeaderStyle', array('spaceAfter' => 0));
$PHPWord->addParagraphStyle('myQuestionStyle', array('spaceAfter' => 0));
// Header
$table = $section->addTable();
$table->addRow();
$table->addCell(4200)->addText('USN: [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]', 'myOwnStyle');
$table->addCell(8000)->addText('');
$table->addCell(700)->addText($subCode, 'myOwnStyle');
$center = array('spaceAfter' => 0, 'align' => 'center');
$table_block_format = array('cellMarginTop' => -10, 'cellMarginLeft' => 30, 'valign' => 'center');
$table_block_format2 = array('cellMarginBottom' => 0, 'cellMarginLeft' => 100, 'valign' => 'center');
$questionTextStyle = array('bold' => false, 'size' => 10.5, 'name' => 'Calibri');
$cellTextStyleBigBold = array('bold' => true, 'size' => 13, 'name' => 'Calibri');
$PHPWord->addTableStyle('myTable', $table_block_format, array('align' => 'center'));
$PHPWord->addTableStyle('myQuestionTable', $table_block_format, array('align' => 'center'));
// $table = $section->addTable('myTable');
// $table->addRow();
// $table->addCell(10000)->addText('Semester '.$sem.', B.E Degree Examination, '.$date, $cellTextStyleBigBold, $center);
// $table->addRow();
// $table->addCell(10000)->addText($subject, $cellTextStyleBigBold, $center);
$section->addText('Dayananda Sagar College of Engineering, Bangalore - 78', $cellTextStyleBigBold, $center);
$section->addText('Department of Computer Science & Engineering', $cellTextStyleBigBold, $center);
$section->addText('Session: ' . $session, $cellTextStyleBigBold, $center);
$section->addText('Internal Assessment - ' . $internal, $cellTextStyleBigBold, $center);
$table = $section->addTable();
$table->addRow();
$cell = $table->addCell(6000);
// $textrun = $cell->createTextRun();
$cell->addText('Semester: ' . $sem, 'myOwnStyle', 'myHeaderStyle');
$cell->addText('Subject: ' . $subject, 'myOwnStyle', 'myHeaderStyle');
$cell->addText('Time: ' . $time, 'myOwnStyle', 'myHeaderStyle');
$table->addCell(4000)->addText('');
$cell = $table->addCell(2100);
// $textrun = $cell->createTextRun();
$cell->addText('Section: ' . $sec, 'myOwnStyle', 'myHeaderStyle');
$cell->addText('Date: ' . $date, 'myOwnStyle', 'myHeaderStyle');
$cell->addText('Max Marks: 50', 'myOwnStyle', 'myHeaderStyle');
// After creating a section, you can append elements:
$listStyle = array('listType' => PHPWord_Style_ListItem::TYPE_NUMBER_NESTED);
$section->addText('PART A', 'myOwnStyle', $center);
$section->addText('Answer any 2 questions out of 3. Each question carries 20 Marks', 'myNoteStyle', $center);
$table = $section->addTable('myQuestionTable');
for ($i = 1; $i <= 3; $i++) {
$letter = 'a';
for ($j = 1; $j <= sizeof($questions[$i]); $j++) {
$table->addRow();
if (sizeof($questions[$i]) == 1) {
$table->addCell(100)->addText($i . '.');
} elseif ($j == 1) {
$table->addCell(100)->addText($i . '.' . $letter++ . ")");
} else {
$table->addCell(100)->addText(" " . $letter++ . ")");
}
$subQuestions = preg_split('/[\\n]/', $questions[$i][$j]->question, -1, NULL);
$cell = $table->addCell(9000);
foreach ($subQuestions as $subQuestion) {
$cell->addText($subQuestion, $questionTextStyle, 'myQuestionStyle');
}
if ($questions[$i][$j]->images()->first()) {
$cell->addImage('images/' . $questions[$i][$j]->images()->first()->path, array('align' => 'center'));
}
if ($j == sizeof($questions[$i])) {
$cell->addText('', 'myGapTStyle', 'myGapPStyle');
}
$table->addCell(100)->addText('(' . $questions[$i][$j]->marks . ')');
}
}
$section->addText('PART B', 'myOwnStyle', $center);
$section->addText('Answer any 1 question out of 2. Each question carries 10 Marks', 'myNoteStyle', $center);
$table = $section->addTable('myQuestionTable');
for ($i = 4; $i <= 5; $i++) {
$letter = 'a';
for ($j = 1; $j <= sizeof($questions[$i]); $j++) {
$table->addRow();
if (sizeof($questions[$i]) == 1) {
$table->addCell(100)->addText($i . '.');
} elseif ($j == 1) {
$table->addCell(100)->addText($i . '.' . $letter++ . ")");
} else {
$table->addCell(100)->addText(" " . $letter++ . ")");
}
$subQuestions = preg_split('/[\\n]/', $questions[$i][$j]->question, -1, NULL);
$cell = $table->addCell(9000);
foreach ($subQuestions as $subQuestion) {
$cell->addText($subQuestion, $questionTextStyle, 'myQuestionStyle');
}
if ($questions[$i][$j]->images()->first()) {
$cell->addImage('images/' . $questions[$i][$j]->images()->first()->path, array('align' => 'center'));
//.........这里部分代码省略.........
示例8: getPHPWordTableXmlStr
/**
* @Title: getWordPHPTableXmlStr
* @Description: todo(用phpword对象生成word表格xml字符串)
* @param $title 表格表名
* @param $titleArr 表头
* @param $titleGroupArr 分组表头 例:array(array("colspan"=>2, "title"=>"第一大组"),array("colspan"=>3, "title"=>"第二大组"))
* @param $data 表数据
* @author 王昭侠
* @date 2015-01-30 上午90:30:00
* @throws
*/
public function getPHPWordTableXmlStr($title, $titleArr, $data = NULL, $titleGroupArr = NULL, $showtype = 0, $textStyle = array(), $widthArray = array())
{
$th_count = count($titleArr);
$obPHPWord = new PHPWord();
$section = $obPHPWord->createSection();
$styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'align' => 'center');
$obPHPWord->addTableStyle('myOwnTableStyle', $styleTable);
$table = $section->addTable('myOwnTableStyle');
$cellStyle = array('borderSize' => 6, 'name' => $textStyle["name"], 'size' => $textStyle["size"], 'spacing' => $textStyle["spacing"], 'borderColor' => '000000', 'cellMargin' => 80);
$td_width = 2000;
$newStats = array();
foreach ($data as $k => $v) {
if ($v["is_stats"] === "1") {
$sum = 0;
if (!empty($v["original"][0]) && is_numeric($v["original"][0])) {
foreach ($v["original"] as $kk => $vv) {
$sum += floatval($vv);
}
$sum = unitExchange($sum, $v["funcdata"][0][0][1], $v["funcdata"][0][0][2], 3);
$newStats[] = "小计:" . $sum;
} else {
$newStats[] = "";
}
} else {
$newStats[] = "";
}
}
$stats = false;
foreach ($newStats as $k => $v) {
if (!empty($v)) {
$stats = true;
break;
}
}
if (!$stats) {
$newStats = array();
}
if (!empty($title)) {
if ($showtype != 0) {
$th_count = count($data[0]["value"]) + 1;
}
$table->addRow();
$table->addCell($td_width * $th_count, array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'align' => 'center', 'gridSpan' => $th_count))->addText($title, array('name' => $textStyle["name"], 'size' => $textStyle["size"], 'spacing' => $textStyle["spacing"], 'align' => 'center'));
}
if (!empty($titleGroupArr)) {
$table->addRow();
foreach ($titleGroupArr as $k => $v) {
$table->addCell($td_width * $v["colspan"], array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'gridSpan' => $v["colspan"]))->addText($v["title"], array('name' => $textStyle["name"], 'size' => $textStyle["size"], 'spacing' => $textStyle["spacing"], 'align' => 'center'));
}
}
if (empty($showtype)) {
//默认为横向输出
if (!empty($titleArr)) {
$table->addRow();
foreach ($titleArr as $k => $v) {
$table->addCell($widthArray[$k] ? $widthArray[$k] : $td_width, array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'valign' => 'center', 'align' => 'center'))->addText($v, $textStyle);
}
}
foreach ($data[0]["value"] as $k => $v) {
$table->addRow();
foreach ($data as $kk => $vv) {
$table->addCell($widthArray[$kk] ? $widthArray[$kk] : $td_width, $cellStyle)->addText($vv["value"][$k], $textStyle);
}
}
if (count($newStats) > 0) {
$table->addRow();
foreach ($newStats as $k => $v) {
$table->addCell($widthArray[$k] ? $widthArray[$k] : $td_width, $cellStyle)->addText($v, $textStyle);
}
}
} else {
if (!empty($titleArr)) {
foreach ($titleArr as $k => $v) {
$table->addRow();
$table->addCell($widthArray[$k] ? $widthArray[$k] : $td_width, array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'align' => 'center'))->addText($v, $textStyle);
if (!empty($data)) {
foreach ($data[$k]["value"] as $kk => $vv) {
$table->addCell($widthArray[$kk] ? $widthArray[$kk] : $td_width, $cellStyle)->addText($vv, $textStyle);
}
}
}
} else {
foreach ($titleArr as $k => $v) {
$table->addRow();
if (!empty($data)) {
foreach ($data[$k]["value"] as $kk => $vv) {
$table->addCell($widthArray[$kk] ? $widthArray[$kk] : $td_width, $cellStyle)->addText($vv, $textStyle);
}
if (count($newStats) > 0) {
//.........这里部分代码省略.........
示例9: PHPWord
$organizacia = $_POST['txt_work_name'];
$pozicia = $_POST['txt_work_position'];
$periodi = $_POST['txt_work_period'];
$PHPWord = new PHPWord();
$section = $PHPWord->CreateSection();
$PHPWord->addFontStyle('rStyle', array('bold' => true, 'size' => 16));
$PHPWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
$section->addText('CV', 'rStyle', 'pStyle');
$section->addTextBreak(2);
$section->addImage($target_file, array('width' => 210, 'height' => 210, 'align' => 'center'));
$section->addTextBreak(2);
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
$fontStyle = array('bold' => true, 'align' => 'center');
$PHPWord->addTableStyle('myOwnTableStyle', $styleTable);
$table = $section->addTable('myOwnTableStyle');
if ($name != '') {
$table->addRow(2);
$table->addCell(4000, $styleCell)->addText('Name', $fontStyle);
$table->addCell(4000, $styleCell)->addText($name, $fontStyle);
}
if ($surname != '') {
$table->addRow();
$table->addCell(4000, $styleCell)->addText('Surname', $fontStyle);
$table->addCell(4000, $styleCell)->addText($surname, $fontStyle);
}
if ($dabadeba != '') {
$table->addRow();
$table->addCell(4000, $styleCell)->addText('Date Of Birth', $fontStyle);
$table->addCell(4000, $styleCell)->addText($dabadeba, $fontStyle);
示例10: PHPWord
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Define table style arrays
$styleTable = array('cellMarginLeft' => 110, 'cellMarginRight' => 110, 'borderSize' => 1);
$styleCellMerged = array('valign' => 'center', 'gridSpan' => 2);
$styleCellBTLR1 = array('vMerge' => 'restart', 'valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
$styleCellBTLR2 = array('vMerge' => 'fusion', 'valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
// Add style definitions
$PHPWord->addParagraphStyle('pStyle', array('spacing' => 100, 'name' => 'Times New Roman', 'bold' => false, 'size' => 11, 'align' => 'center', 'spaceAfter' => 100));
$PHPWord->addFontStyle('BoldText', array('name' => 'Times New Roman', 'bold' => true, 'size' => 12));
$PHPWord->addFontStyle('texto', array('name' => 'Arial', 'bold' => false, 'size' => 11));
$PHPWord->addFontStyle('texto_sublinhado', array('name' => 'Arial', 'bold' => false, 'size' => 11, 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE));
$PHPWord->addFontStyle('titulo', array('name' => 'Thorndale', 'size' => 12, 'bold' => false, 'align' => 'center', 'spaceAfter' => 100));
// Add table style
$PHPWord->addTableStyle('tbl13', $styleTable);
// Add header
$header = $section->createHeader();
// Add table
$table = $header->addTable('tbl13');
// variaveis que recebem o texto
$assunto = utf8_decode($documento->getAssunto());
$msg2 = utf8_decode("SISTEMA TRONCAL DE ÔNIBUS DA REGIÃO METROPOLITANA DE BELÉM");
$pagina = utf8_decode("Página");
$local = utf8_decode($documento->getLocal());
$observacao = utf8_decode($documento->getObservacao());
//documento
$table->addRow();
$styleCell = array('gridSpan' => 2);
$styleTable = array('cellMarginLeft' => 110, 'cellMarginRight' => 110, 'borderSize' => 1);
$table->addCell(2500, array('vMerge' => 'restart'))->addImage('C:/Diego/troncal.jpg', array('width' => 170, 'height' => 50, 'align' => 'left'));
示例11: offlinequiz_create_docx_question
/**
* Generates the DOCX question/correction form for an offlinequiz group.
*
* @param question_usage_by_activity $templateusage the template question usage for this offline group
* @param object $offlinequiz The offlinequiz object
* @param object $group the offline group object
* @param int $courseid the ID of the Moodle course
* @param object $context the context of the offline quiz.
* @param boolean correction if true the correction form is generated.
* @return stored_file instance, the generated DOCX file.
*/
function offlinequiz_create_docx_question(question_usage_by_activity $templateusage, $offlinequiz, $group, $courseid, $context, $correction = false)
{
global $CFG, $DB, $OUTPUT;
$letterstr = 'abcdefghijklmnopqrstuvwxyz';
$groupletter = strtoupper($letterstr[$group->number - 1]);
$coursecontext = context_course::instance($courseid);
PHPWord_Media::resetMedia();
$docx = new PHPWord();
$trans = new offlinequiz_html_translator();
// Define cell style arrays.
$cellstyle = array('valign' => 'center');
// Add text styles.
// Normal style.
$docx->addFontStyle('nStyle', array('size' => $offlinequiz->fontsize));
// Italic style.
$docx->addFontStyle('iStyle', array('italic' => true, 'size' => $offlinequiz->fontsize));
// Bold style.
$docx->addFontStyle('bStyle', array('bold' => true, 'size' => $offlinequiz->fontsize));
$docx->addFontStyle('brStyle', array('bold' => true, 'align' => 'right', 'size' => $offlinequiz->fontsize));
// Underline style.
$docx->addFontStyle('uStyle', array('underline' => PHPWord_Style_Font::UNDERLINE_SINGLE, 'size' => $offlinequiz->fontsize));
$docx->addFontStyle('ibStyle', array('italic' => true, 'bold' => true, 'size' => $offlinequiz->fontsize));
$docx->addFontStyle('iuStyle', array('italic' => true, 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE, 'size' => $offlinequiz->fontsize));
$docx->addFontStyle('buStyle', array('bold' => true, 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE, 'size' => $offlinequiz->fontsize));
$docx->addFontStyle('ibuStyle', array('italic' => true, 'bold' => true, 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE, 'size' => $offlinequiz->fontsize));
// Header style.
$docx->addFontStyle('hStyle', array('bold' => true, 'size' => $offlinequiz->fontsize + 4));
// Center style.
$docx->addParagraphStyle('cStyle', array('align' => 'center', 'spaceAfter' => 100));
$docx->addParagraphStyle('cStyle', array('align' => 'center', 'spaceAfter' => 100));
$docx->addParagraphStyle('questionTab', array('tabs' => array(new PHPWord_Style_Tab("left", 360))));
// Define table style arrays.
$tablestyle = array('borderSize' => 0, 'borderColor' => 'FFFFFF', 'cellMargin' => 20, 'align' => 'center');
$firstrowstyle = array('borderBottomSize' => 0, 'borderBottomColor' => 'FFFFFF', 'bgColor' => 'FFFFFF');
$docx->addTableStyle('tableStyle', $tablestyle, $firstrowstyle);
$boldfont = new PHPWord_Style_Font();
$boldfont->setBold(true);
$boldfont->setSize($offlinequiz->fontsize);
$normalfont = new PHPWord_Style_Font();
$normalfont->setSize($offlinequiz->fontsize);
// Define custom list item style for question answers.
$level1 = new PHPWord_Style_Paragraph();
$level1->setTabs(new PHPWord_Style_Tabs(array(new PHPWord_Style_Tab('clear', 720), new PHPWord_Style_Tab('num', 360))));
$level1->setIndentions(new PHPWord_Style_Indentation(array('left' => 360, 'hanging' => 360)));
$level2 = new PHPWord_Style_Paragraph();
$level2->setTabs(new PHPWord_Style_Tabs(array(new PHPWord_Style_Tab('left', 720), new PHPWord_Style_Tab('num', 720))));
$level2->setIndentions(new PHPWord_Style_Indentation(array('left' => 720, 'hanging' => 360)));
// Create the section that will be used for all outputs.
$section = $docx->createSection();
$title = offlinequiz_str_html_docx($offlinequiz->name);
if (!empty($offlinequiz->time)) {
if (strlen($title) > 35) {
$title = substr($title, 0, 33) . ' ...';
}
$title .= ": " . offlinequiz_str_html_docx(userdate($offlinequiz->time));
} else {
if (strlen($title) > 40) {
$title = substr($title, 0, 37) . ' ...';
}
}
$title .= ", " . offlinequiz_str_html_docx(get_string('group') . " {$groupletter}");
// Add a header.
$header = $section->createHeader();
$header->addText($title, array('size' => 10), 'cStyle');
$header->addImage($CFG->dirroot . '/mod/offlinequiz/pix/line.png', array('width' => 600, 'height' => 5, 'align' => 'center'));
// Add a footer.
$footer = $section->createFooter();
$footer->addImage($CFG->dirroot . '/mod/offlinequiz/pix/line.png', array('width' => 600, 'height' => 5, 'align' => 'center'));
$footer->addPreserveText($title . ' | ' . get_string('page') . ' ' . '{PAGE} / {NUMPAGES}', null, array('align' => 'left'));
// Print title page.
if (!$correction) {
$section->addText(offlinequiz_str_html_docx(get_string('questionsheet', 'offlinequiz') . ' - ' . get_string('group') . " {$groupletter}"), 'hStyle', 'cStyle');
$section->addTextBreak(2);
$table = $section->addTable('tableStyle');
$table->addRow();
$cell = $table->addCell(200, $cellstyle)->addText(offlinequiz_str_html_docx(get_string('name')) . ': ', 'brStyle');
$table->addRow();
$cell = $table->addCell(200, $cellstyle)->addText(offlinequiz_str_html_docx(get_string('idnumber', 'offlinequiz')) . ': ', 'brStyle');
$table->addRow();
$cell = $table->addCell(200, $cellstyle)->addText(offlinequiz_str_html_docx(get_string('studycode', 'offlinequiz')) . ': ', 'brStyle');
$table->addRow();
$cell = $table->addCell(200, $cellstyle)->addText(offlinequiz_str_html_docx(get_string('signature', 'offlinequiz')) . ': ', 'brStyle');
$section->addTextBreak(2);
// The DOCX intro text can be arbitrarily long so we have to catch page overflows.
if (!empty($offlinequiz->pdfintro)) {
$blocks = offlinequiz_convert_image_docx($offlinequiz->pdfintro);
offlinequiz_print_blocks_docx($section, $blocks);
}
$section->addPageBreak();
//.........这里部分代码省略.........