将word内容追击到新建WORD文档
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将word内容追击到新建WORD文档相关的知识,希望对你有一定的参考价值。
将word内容追击到新建WORD文档
Microsoft.Office.Interop.Word._Application wordApp = new Microsoft.Office.Interop.Word.Application(); wordApp.Visible = false; Object Nothing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word._Document document = new DocumentClass(); Microsoft.Office.Interop.Word._Document tempdocument = new DocumentClass(); object objTemplate = Server.MapPath(@"~\\wordModel\demo.doc"); document = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing); for (int i = 0; i < 3; i++) { //document.Content. if (i > 0) { Microsoft.Office.Interop.Word.Paragraph para; para = document.Content.Paragraphs.Add(ref Nothing); object pBreak = (int)WdBreakType.wdSectionBreakNextPage; para.Range.InsertBreak(ref pBreak); } tempdocument = wordApp.Documents.Open(objTemplate); Range range = tempdocument.Range(ref Nothing, ref Nothing); range.Copy(); document.Paragraphs.Last.Range.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting); }
以上是关于将word内容追击到新建WORD文档的主要内容,如果未能解决你的问题,请参考以下文章
Java怎么操作OpenOffice创建word文档并向其设置内容