php - 在 PHPWORD 中重复 ListItem 编号
问题描述
有没有办法重复 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);
推荐阅读
- javascript - 播放后如何重置 CSS 过渡
- android - 尝试在颤振中使用自定义 EventChannel 时出现 MissingPluginException
- c++ - gcc 应用程序运行不正常,但 clang 工作正常
- python - 具有重复命名标记的 ParseResults 输出结构:如何保持命名字典中的顺序
- node.js - 如何使用 mongoose 创建由家长管理的学生
- c# - OleDbDataAdapter::Fill 不是完整的单元格数据
- apache-spark - 我们可以从 AVRO 模式自动生成 Spark SQL 查询吗?
- android - 将画廊中的图像路径保存到 Room DB,然后在 Picasso 不工作的情况下加载
- apache-spark - 在 pyspark 数据框中添加具有另一列最大值的新列
- xamarin - 如何在 Xamarin Forms 应用程序中实现地图导航系统?