最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Cannot create numbered headings using PHPWord - Stack Overflow

programmeradmin2浏览0评论

I have PhpWord installed and running. I am unable to add numbers to the headings.

This is the code I am using:

AddNumberStyle();
AddTitleStyle(1);
AddTitleStyle(2);
AddTitleStyle(3);
$section->addTitle('Hello',1);
$section->addTitle('Hello',2);
$section->addTitle('Hello',3);

function AddNumberStyle() {
global $phpWord;
$StyleName='headingNumbering';
$Style1['pStyle']='Heading1';$Style1['format']='decimal';$Style1['text']='%1';
$Style2['pStyle']='Heading2';$Style2['format']='decimal';$Style2['text']='%1.%2';
$Style3['pStyle']='Heading3';$Style3['format']='decimal';$Style3['text']='%1.%2.%3';
$Levels['type']='multilevel';
$Levels['levels']=[$Style1,$Style2,$Style3];
$phpWord->addNumberingStyle($StyleName,$Levels);
}

function AddTitleStyle($Number) {
global $phpWord;
$Font['size']=14;
$Font['bold']=true;
$Format['numStyle']='hNum';
$Format['numLevel']=$Number;
$phpWord->addTitleStyle($Number,$Font,$Format);
}

The word doc generated has:

Hello Hello Hello

What' needed is:

1. Hello 1.1 Hello 1.1.1 Hello

发布评论

评论列表(0)

  1. 暂无评论