2015-12-21 111 views
0

我正在使用PhpWord庫來生成docx文件。PHPWord和ListItemRun,重置編號

在我需要生成HTML從這個文件,所以如果我想生成數字列表,我需要使用

$section->addListItemRun(); 

所以,如果我我期待的結果

文件中生成兩個列表大多數情況下,
1.Item 1 
2.Item 2 
3.Item 3 

Some text here 

1.Item 1 
2.Item 2 
3.Item 3 

但是我卻越來越

1.Item 1 
2.Item 2 
3.Item 3 

Some text here 

4.Item 1 
5.Item 2 
6.Item 3 

有誰知道我怎麼可以重新編號?

另一個問題,這個庫可以用這種方法

$section->addFootnote(); 

我可以更改腳註的標籤添加腳註?

謝謝

回答

0

這是單詞中的行爲。不是文件。 但你可以創建獨特的名單破解

$n = 1; 
    foreach ($lists as $list) { 
     // Hack to reset lists 
     $listFormat = $phpWord->addNumberingStyle(
      'multilevel-'.$n, 
      array('type' => 'multilevel', 'levels' => array(
        array('format' => 'decimal', 'text' => '%1.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720)      
       ) 
      ) 
     ); 
     $section->addText(htmlspecialchars('Multilevel list.')); 
     $section->addListItem(htmlspecialchars('List Item I'), 0, null, 'multilevel-'.$n); 
     $section->addListItem(htmlspecialchars('List Item I.a'), 1, null, 'multilevel-'.$n); 
     $section->addListItem(htmlspecialchars('List Item I.b'), 1, null, 'multilevel-'.$n); 
     $section->addListItem(htmlspecialchars('List Item II'), 0, null, 'multilevel-'.$n); 
     $section->addListItem(htmlspecialchars('List Item II.a'), 1, null, 'multilevel-'.$n); 
     $section->addListItem(htmlspecialchars('List Item III'), 0, null, 'multilevel-'.$n); 
     $section->addTextBreak(2); 
     $n++; 
    }