任何人都可以幫助我通過Java編碼將模板附加到word文檔。通過JAVA將模板附加到word文檔中
0
A
回答
0
如果您知道如何在VBA中執行此操作,可以使用Com4J,爲Java生成JavaProxies,然後從Java調用相同的函數。
0
嘗試Apache POI,它提供了用於操作MS Office文檔的跨平臺純Java解決方案。
0
與docx4j:
// Create settings part, and init content
DocumentSettingsPart dsp = new DocumentSettingsPart();
CTSettings settings = Context.getWmlObjectFactory().createCTSettings();
dsp.setJaxbElement(settings);
wordMLPackage.getMainDocumentPart().addTargetPart(dsp);
// Create external rel
RelationshipsPart rp = RelationshipsPart.createRelationshipsPartForPart(dsp);
org.docx4j.relationships.Relationship rel = new org.docx4j.relationships.ObjectFactory().createRelationship();
rel.setType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate" );
rel.setTarget("file:///C:\\Users\\jsmith\\AppData\\Roaming\\Microsoft\\Templates\\yours.dotm");
rel.setTargetMode("External");
rp.addRelationship(rel); // addRelationship sets the rel's @Id
settings.setAttachedTemplate(
(CTRel)XmlUtils.unmarshalString("<w:attachedTemplate xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"" + rel.getId() + "\"/>", Context.jc, CTRel.class)
);
見org.docx4j.samples.TemplateAttach在docx4j svn的爲完整的例子。
相關問題
- 1. 如何將Word模板附加到VB.NET中的新文檔中?
- 2. Java:如何將剪貼板上的圖像粘貼(附加)到word文檔
- 3. 微軟Word VBA:獲取文檔的附加模板
- 4. 文件附加在word文檔中
- 5. 如何使用docx4j將文件附加到MS Word文檔?
- 6. 如何通過模板以編程方式創建Word文檔
- 7. 將WordprocessingML添加到word文檔中
- 8. 使用PHP將Word文檔添加到另一個Word文檔
- 9. 通過搜索和替換Excel數據到Word模板 - 多個文檔
- 10. 通過swiftmailer發送附加文檔
- 11. 將標題添加到Word文檔?
- 12. 將通過POI生成的文件附加到便籤文檔中
- 13. .net模板引擎生成word文檔
- 14. 文檔模板:用JavaScript代替Word?
- 15. Word 2003模板 - 文檔保存
- 16. 使用vbscript將xml文件導入word文檔模板
- 17. 比較文檔模板Word文檔文件(.docx)(.DOTX)
- 18. 使用java從模板創建word文檔
- 19. 將XML文檔附加到現有文檔中
- 20. 生成一個Word文檔,其中的圖像通過SSL嵌入到JAVA中
- 21. 將HTML元素附加到文檔
- 22. 將jquery插件附加到文檔
- 23. 將剪貼板中的圖像粘貼到word文檔
- 24. Dynamics CRM 365:通過功能區上的按鈕下載Word文檔模板
- 25. 附加到GridViewColumnHeader模板
- 26. 如何附加到Word文檔與VBA宏
- 27. ASP.NET:如何附加簽名到Word文檔
- 28. 如何將當前活動的Word文檔中通過的OpenXML
- 29. 通過C#Word文檔許可#
- 30. 通過OpenXML生成word文檔
我有VBA編碼附加的tenplates如下: – Bhuvana 2011-03-04 11:23:41