当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpWord::addNumberingStyle方法代码示例

本文整理汇总了PHP中PhpOffice\PhpWord\PhpWord::addNumberingStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpWord::addNumberingStyle方法的具体用法?PHP PhpWord::addNumberingStyle怎么用?PHP PhpWord::addNumberingStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpOffice\PhpWord\PhpWord的用法示例。


在下文中一共展示了PhpWord::addNumberingStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testWriteNumbering

 /**
  * Write footnotes
  */
 public function testWriteNumbering()
 {
     $xmlFile = 'word/numbering.xml';
     $phpWord = new PhpWord();
     $phpWord->addNumberingStyle('numStyle', array('type' => 'multilevel', 'levels' => array(array('start' => 1, 'format' => 'decimal', 'restart' => 1, 'suffix' => 'space', 'text' => '%1.', 'alignment' => Jc::START, 'left' => 360, 'hanging' => 360, 'tabPos' => 360, 'font' => 'Arial', 'hint' => 'default'))));
     $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
     $this->assertTrue($doc->elementExists('/w:numbering/w:abstractNum', $xmlFile));
 }
开发者ID:HaiLeader,项目名称:quizz,代码行数:11,代码来源:NumberingTest.php

示例2: read

 /**
  * Read numbering.xml.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  */
 public function read(PhpWord $phpWord)
 {
     $abstracts = array();
     $numberings = array();
     $xmlReader = new XMLReader();
     $xmlReader->getDomFromZip($this->docFile, $this->xmlFile);
     // Abstract numbering definition
     $nodes = $xmlReader->getElements('w:abstractNum');
     if ($nodes->length > 0) {
         foreach ($nodes as $node) {
             $abstractId = $xmlReader->getAttribute('w:abstractNumId', $node);
             $abstracts[$abstractId] = array('levels' => array());
             $abstract =& $abstracts[$abstractId];
             $subnodes = $xmlReader->getElements('*', $node);
             foreach ($subnodes as $subnode) {
                 switch ($subnode->nodeName) {
                     case 'w:multiLevelType':
                         $abstract['type'] = $xmlReader->getAttribute('w:val', $subnode);
                         break;
                     case 'w:lvl':
                         $levelId = $xmlReader->getAttribute('w:ilvl', $subnode);
                         $abstract['levels'][$levelId] = $this->readLevel($xmlReader, $subnode, $levelId);
                         break;
                 }
             }
         }
     }
     // Numbering instance definition
     $nodes = $xmlReader->getElements('w:num');
     if ($nodes->length > 0) {
         foreach ($nodes as $node) {
             $numId = $xmlReader->getAttribute('w:numId', $node);
             $abstractId = $xmlReader->getAttribute('w:val', $node, 'w:abstractNumId');
             $numberings[$numId] = $abstracts[$abstractId];
             $numberings[$numId]['numId'] = $numId;
             $subnodes = $xmlReader->getElements('w:lvlOverride/w:lvl', $node);
             foreach ($subnodes as $subnode) {
                 $levelId = $xmlReader->getAttribute('w:ilvl', $subnode);
                 $overrides = $this->readLevel($xmlReader, $subnode, $levelId);
                 foreach ($overrides as $key => $value) {
                     $numberings[$numId]['levels'][$levelId][$key] = $value;
                 }
             }
         }
     }
     // Push to Style collection
     foreach ($numberings as $numId => $numbering) {
         $phpWord->addNumberingStyle("PHPWordList{$numId}", $numbering);
     }
 }
开发者ID:brunodebarros,项目名称:phpword,代码行数:56,代码来源:Numbering.php


注:本文中的PhpOffice\PhpWord\PhpWord::addNumberingStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。