我使用phpword生成MS Word文档,有没有什么办法可以帮助我在生成的文件末尾生成索引?MS Word文档文件生成索引
我认为可行的一种方法是读取生成的MS Word文件并找到每个单词的位置(例如MS Word文件中的页码),然后在单独的MS Word文件中重新生成索引。
有没有更好的方法?所需文件的
例子:
A
Animal 51,98
Apple 11,54,99
B
Basket 55
...
..
etc
我使用phpword生成MS Word文档,有没有什么办法可以帮助我在生成的文件末尾生成索引?MS Word文档文件生成索引
我认为可行的一种方法是读取生成的MS Word文件并找到每个单词的位置(例如MS Word文件中的页码),然后在单独的MS Word文件中重新生成索引。
有没有更好的方法?所需文件的
例子:
A
Animal 51,98
Apple 11,54,99
B
Basket 55
...
..
etc
我supose,你可以读取文件的标题:阅读这个帖子,不正是你想要什么,但也许有修改可能是正确的做法:
Automatically generate nested table of contents based on heading tags
链接可以[腐烂](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers)!提供有关链接的简要信息,然后将其添加为参考 –
我认为这将有助于你
链接可以[rot](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really - 良好 - 答案)!提供有关链接的简要信息,然后将其添加为参考 –
@Bhuvan Rikka ok thankz for your information ............ – Kichu
@BhuvanRikka웃,this this'http://stackoverflow.com/questions/15496461/usps-not-working-magento-1-7-ce'试图寻找解决方案....... – Kichu
老实说,我不认为你在这里有很多好的选择。我仔细研究了一下,因为它对我来说也很有趣,但除了你的帖子之外,我还没有在phpword文档或论坛上找到关于如何使这成为可能的东西。 在背面,你可以尝试解压缩docx包(这是一个zip文件)并直接操作XML文件。我不知道这将如何去...假设,做对了,这是没有什么不同,如果它是手动在Word中完成。我通过使用一些填充文本进行了实验,并手动在文档中的一个术语上为索引执行“全部标记”。我能找到的是以下几点:
再添作为第一个孩子在〜/ [CONTENT_TYPES] .XML:
<Override PartName="/customXml/itemProps1.xml" ContentType="application/vnd.openxmlformats-officedocument.customXmlProperties+xml" />
创建的文件夹〜/ CustomXml -
在〜/ CustomXml文件夹,创建item1.xml:
<b:Sources SelectedStyle="\APA.XSL" StyleName="APA" xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"></b:Sources>
在〜/ CustomXml文件夹中,创建itemProps1.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ds:datastoreItem ds:itemID="{3DC430FE-7F6E-49D7-9EFC-E4F37E42ABA0}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml">
<ds:schemaRefs>
<ds:schemaRef ds:uri="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"/>
</ds:schemaRefs>
</ds:datastoreItem>
创建的文件夹〜/ CustomXml/_rels: 在〜/ CustomXml/_rels文件夹,创建item1.xml.rels:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps" Target="itemProps1.xml"/>
</Relationships>
的〜/ docProps文件夹改变,但它是无关紧要的字回收物/在每次打开/关闭时更新这些值,并且它们对文件内容没有任何影响。
基本上,这留下了〜/ word文件夹。 所以,〜/字/ styles.xml变化在末尾添加一个风格指数,具体如下:
<w:style w:type="paragraph" w:styleId="Index1">
<w:name w:val="index 1"/>
<w:basedOn w:val="Normal"/>
<w:next w:val="Normal"/>
<w:autoRedefine/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val="00C52B35"/>
<w:pPr>
<w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
<w:ind w:left="220" w:hanging="220"/>
</w:pPr>
</w:style>
的宽:RSID元素在〜/字/ settings.xml的一切都变了,老老实实,这些都是分散的,我不确定他们是如何工作/计算的,或者他们是否太重要。
In〜/ word/_rels/document.xml。RELS,下面加入作为关系节点的子:
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXml/item1.xml"/>
最后,也许是最重要的,在〜/字/ document.xml中,我的索引项(“坐”)的每次出现后跟由以下元素:
<w:r w:rsidR="00C52B35">
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r w:rsidR="00C52B35">
<w:instrText xml:space="preserve">XE "</w:instrText>
</w:r>
<w:r w:rsidR="00C52B35" w:rsidRPr="00C90937">
<w:instrText>sit</w:instrText>
</w:r>
<w:r w:rsidR="00C52B35">
<w:instrText xml:space="preserve">"</w:instrText>
</w:r>
<w:r w:rsidR="00C52B35">
<w:fldChar w:fldCharType="end"/>
</w:r>
还有在最后,我插入的索引一点点:
<w:p w:rsidR="00C52B35" w:rsidRDefault="00C52B35" w:rsidP="00DE5AB4">
<w:pPr>
<w:rPr>
<w:b/>
<w:noProof/>
</w:rPr>
<w:sectPr w:rsidR="00C52B35" w:rsidSect="00C52B35">
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:instrText xml:space="preserve">INDEX \c "2" \z "1033"</w:instrText>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:fldChar w:fldCharType="separate"/>
</w:r>
</w:p>
<w:p w:rsidR="00C52B35" w:rsidRDefault="00C52B35">
<w:pPr>
<w:rPr>
<w:noProof/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:lastRenderedPageBreak/>
<w:br w:type="page"/>
</w:r>
</w:p>
<w:p w:rsidR="00C52B35" w:rsidRDefault="00C52B35">
<w:pPr>
<w:pStyle w:val="Index1"/>
<w:tabs>
<w:tab w:val="right" w:leader="dot" w:pos="4310"/>
</w:tabs>
<w:rPr>
<w:noProof/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:lastRenderedPageBreak/>
<w:t>sit, 1, 2</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00C52B35" w:rsidRDefault="00C52B35" w:rsidP="00DE5AB4">
<w:pPr>
<w:rPr>
<w:b/>
<w:noProof/>
</w:rPr>
<w:sectPr w:rsidR="00C52B35" w:rsidSect="00C52B35">
<w:type w:val="continuous"/>
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:num="2" w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:pPr>
</w:p>
<w:p w:rsidR="00371DB1" w:rsidRPr="00371DB1" w:rsidRDefault="00C52B35" w:rsidP="00DE5AB4">
<w:pPr>
<w:rPr>
<w:b/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:lastRenderedPageBreak/>
<w:fldChar w:fldCharType="end"/>
</w:r>
</w:p>
希望这有助于。我知道这是一个复杂的解决方案,但它是我能找到的唯一能帮助你并以自动化的方式实现这一点的唯一方法。它稍微有点跳动the official, manual way of doing this,并且应该保持你这样做的索引的特征。我建议如果你认真地做到这一点,使用WinMerge来查看文件之间的差异(右键单击并使用比较特殊> XML,一旦你打开两个文件夹),祝你好运。如果它是一次性的,我只是咬下子弹并手动完成。它可能更快,头痛也更少。
该文件有多大?你需要处理多少文件?这只是一个文件生成,或者你必须创建系统,生成索引供以后使用? – Kamil
@Kamil只是一个字的文件,第一个生成的文件约200页。 – shox