我使用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