本文整理汇总了PHP中PHPWord::addTitleStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord::addTitleStyle方法的具体用法?PHP PHPWord::addTitleStyle怎么用?PHP PHPWord::addTitleStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWord
的用法示例。
在下文中一共展示了PHPWord::addTitleStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PHPWord
include_once "header.php";
$dates = dates_range($_POST['start'], $_POST['end']);
$myts =& MyTextSanitizer::getInstance();
$sitename = $myts->addSlashes($xoopsConfig['sitename']);
$page_title = "{$sitename} {$_POST['start']}~{$_POST['end']}" . _MD_TADCAL_SIMPLE_CAL;
$filename = str_replace(" ", "", $page_title);
require_once XOOPS_ROOT_PATH . "/modules/tadtools/PHPWord.php";
$PHPWord = new PHPWord();
$PHPWord->setDefaultFontSize(9);
//設定預設字型大小
$sectionStyle = array('orientation' => 'portrait', 'marginTop' => 900, 'marginLeft' => 900, 'marginRight' => 900, 'marginBottom' => 900);
$cw = array(_MD_TADCAL_SU, _MD_TADCAL_MO, _MD_TADCAL_TU, _MD_TADCAL_WE, _MD_TADCAL_TH, _MD_TADCAL_FR, _MD_TADCAL_SA);
$section = $PHPWord->createSection($sectionStyle);
$fontStyle = array('color' => '000000', 'size' => 16, 'bold' => true);
$PHPWord->addTitleStyle(1, $fontStyle);
$section->addTitle($page_title, 1);
$contentfontStyle = array('color' => '000000', 'size' => 9, 'bold' => false);
$styleTable = array('borderColor' => '000000', 'borderSize' => 6, 'cellMargin' => 50);
$styleFirstRow = array('bgColor' => 'CFCFCF');
//首行樣式
$PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);
//建立表格樣式
$table = $section->addTable('myTable');
//建立表格
$cellStyle = array('valign' => 'center');
//儲存格樣式(設定項:valign、textDirection、bgColor、borderTopSize、borderTopColor、borderLeftSize、borderLeftColor、borderRightSize、borderRightColor、borderBottomSize、borderBottomColor)
$paraStyle = array('align' => 'center');
$headStyle = array('bold' => true);
//取得目前使用者可讀的群組
$ok_cate_arr = chk_tad_cal_cate_power('enable_group');
示例2: PHPWord
<?php
require_once '../PHPWord.php';
// New Word Document
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Define the TOC font style
$fontStyle = array('spaceAfter' => 60, 'size' => 12);
// Add title styles
$PHPWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$PHPWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
// Add text elements
$section->addText('Table of contents:');
$section->addTextBreak(2);
// Add TOC
$section->addTOC($fontStyle);
// Add Titles
$section->addPageBreak();
$section->addTitle('I am Title 1', 1);
$section->addText('Some text...');
$section->addTextBreak(2);
$section->addTitle('I am a Subtitle of Title 1', 2);
$section->addTextBreak(2);
$section->addText('Some more text...');
$section->addTextBreak(2);
$section->addTitle('Another Title (Title 2)', 1);
$section->addText('Some text...');
$section->addPageBreak();
$section->addTitle('I am Title 3', 1);
$section->addText('And more text...');
示例3: doDoc
function doDoc($title, $headertext, $footertext, $items)
{
// New Word Document
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Add header
$header = $section->createHeader();
$table = $header->addTable();
$table->addRow();
$table->addCell(4500)->addText($headertext);
// Add footer
$footer = $section->createFooter();
//$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align'=>'center'));
$footer->addPreserveText($footertext, array('align' => 'center'));
// Title styles
$PHPWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$PHPWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
$section->addTitle($title, 1);
foreach ($items as $item) {
$section->addTitle($item->title, 2);
$section->addTextBreak(1);
$section->addText($item->text);
$section->addTextBreak(1);
$section->addImage($item->filename);
$section->addTextBreak(1);
}
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
header('Content-Type: application/vnd.ms-word');
header('Content-Disposition: attachment;filename="' . $title . '.docx"');
header('Cache-Control: max-age=0');
// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('php://output');
}