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

phpWord make Table of Contents text different from section titles text? - Stack Overflow

programmeradmin2浏览0评论

In phpWord, I would like to modify the text that appears on the Table of Contents to be different from what appears in the individual section titles.

// Add title styles
$phpWord->addTitleStyle(1,[],[]);

// Add TOC
$toc = $section->addTOC();

//Section 0
$section = $phpWord->addSection();
$section->addTitle('Section 00', 1);

//Section 1
$section = $phpWord->addSection();
$section->addTitle('Section 01', 1);

//Section 2
$section = $phpWord->addSection();
$section->addTitle('Section 02', 1);

This will produce a Table of Contents that looks like this:

Section 00......................2

Section 01......................3

Section 02......................4

Is there a way to make the text on the Table of Contents display something different from the text that is printed in the actual sections?

What I want:

Section 00.............................2

Section 01 (Not Applicable)............3

Section 02 (Will be submitted Later)...4

I still want the sections of the document to have the titles Section 00, Section 01, Section 02; but I want to be able to modify the text that appears in the TOC.

Is that possible?

What I'm hoping is that something like the line below exists, but I can't find anything like that in the documentation.

$section->addTitle('Section 01', 1,['altext' => 'Section 01 (Not Applicable)']);
发布评论

评论列表(0)

  1. 暂无评论