本文整理汇总了PHP中PhpOffice\PhpWord\PhpWord::getSections方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWord::getSections方法的具体用法?PHP PhpWord::getSections怎么用?PHP PhpWord::getSections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpWord\PhpWord
的用法示例。
在下文中一共展示了PhpWord::getSections方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAutoStyles
/**
* Get automatic styles.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/
private function getAutoStyles(PhpWord $phpWord)
{
$sections = $phpWord->getSections();
$paragraphStyleCount = 0;
$fontStyleCount = 0;
foreach ($sections as $section) {
$style = $section->getStyle();
$style->setStyleName("Section{$section->getSectionId()}");
$this->autoStyles['Section'][] = $style;
$this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount);
}
}
示例2: testCreateGetSections
/**
* Test create/get section
*/
public function testCreateGetSections()
{
$phpWord = new PhpWord();
$phpWord->addSection();
$this->assertCount(1, $phpWord->getSections());
}
示例3: getAutomaticStyles
/**
* Set automatic styles
*/
private function getAutomaticStyles(PhpWord $phpWord)
{
$sections = $phpWord->getSections();
$sectionCount = count($sections);
if ($sectionCount > 0) {
$paragraphStyleCount = 0;
$fontStyleCount = 0;
foreach ($sections as $section) {
$elements = $section->getElements();
foreach ($elements as $element) {
if ($element instanceof Text) {
$fontStyle = $element->getFontStyle();
$paragraphStyle = $element->getParagraphStyle();
// Font
if ($fontStyle instanceof Font) {
$fontStyleCount++;
$arrStyle = array('color' => $fontStyle->getColor(), 'name' => $fontStyle->getName());
$phpWord->addFontStyle('T' . $fontStyleCount, $arrStyle);
$element->setFontStyle('T' . $fontStyleCount);
// Paragraph
} elseif ($paragraphStyle instanceof Paragraph) {
$paragraphStyleCount++;
$phpWord->addParagraphStyle('P' . $paragraphStyleCount, array());
$element->setParagraphStyle('P' . $paragraphStyleCount);
}
}
}
}
}
}
示例4: testCreateGetSections
/**
* Test create/get section
*/
public function testCreateGetSections()
{
$phpWord = new PhpWord();
$this->assertEquals(new Section(1), $phpWord->addSection());
$phpWord->addSection();
$this->assertEquals(2, count($phpWord->getSections()));
}