在 PHPWORD 中重复 ListItem 编号
Repeat ListItem Numbering in PHPWORD
有没有办法重复 ListItem 编号(字母)?
PHPWORD 包
目前,输出是:
1. One
2. Two
A. Alpha
B. Beta
3. Three
A. Charlie
我要输出这个:
1. One
2. Two
A. Alpha
B. Beta
2. Three
A. Charlie
$multilevelList1 = 'multilevel list 1'; // Normal numbering style
$multilevelList2 = 'multilevel list 2'; // Same style as previous one, but level 0 starts at 2 instead of 1
$phpWord->addNumberingStyle(
$multilevelList1,
array(
'type' => 'multilevel',
'levels' => array(
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360,
'start' => 1),
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
),
)
);
$phpWord->addNumberingStyle(
$multilevelList2,
array(
'type' => 'multilevel',
'levels' => array(
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360,
'start' => 2),
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
),
)
);
// New section
$section = $phpWord->addSection();
// Lists
$section->addListItem('One', 0, null, $multilevelList1);
$section->addListItem('Two', 0, null, $multilevelList1);
$section->addListItem('Alpha', 1, null, $multilevelList1);
$section->addListItem('Beta', 1, null, $multilevelList1);
$section->addListItem('Three', 0, null, $multilevelList2);
$section->addListItem('Charlie', 1, null, $multilevelList2);
有没有办法重复 ListItem 编号(字母)?
PHPWORD 包
目前,输出是:
1. One
2. Two
A. Alpha
B. Beta
3. Three
A. Charlie
我要输出这个:
1. One
2. Two
A. Alpha
B. Beta
2. Three
A. Charlie
$multilevelList1 = 'multilevel list 1'; // Normal numbering style
$multilevelList2 = 'multilevel list 2'; // Same style as previous one, but level 0 starts at 2 instead of 1
$phpWord->addNumberingStyle(
$multilevelList1,
array(
'type' => 'multilevel',
'levels' => array(
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360,
'start' => 1),
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
),
)
);
$phpWord->addNumberingStyle(
$multilevelList2,
array(
'type' => 'multilevel',
'levels' => array(
array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360,
'start' => 2),
array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
),
)
);
// New section
$section = $phpWord->addSection();
// Lists
$section->addListItem('One', 0, null, $multilevelList1);
$section->addListItem('Two', 0, null, $multilevelList1);
$section->addListItem('Alpha', 1, null, $multilevelList1);
$section->addListItem('Beta', 1, null, $multilevelList1);
$section->addListItem('Three', 0, null, $multilevelList2);
$section->addListItem('Charlie', 1, null, $multilevelList2);