在一个存在的文件中写入新的单词页面 [英] write in new word page in an existant document

查看:44
本文介绍了在一个存在的文件中写入新的单词页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我添加 并在一个带有c#的existant文档字的新页面中编写,我的程序现在写在文档的最后一行之后,我不会创建一个新页面之后和写入

can any one help me to add  and write in a new page in an existant document word with c#,my program now write just after the last line of the document,i wont that it will create a new page after and write in

推荐答案

你好Amin_tn。

Hi Amin_tn.

我的代码添加一个新的休息页面现有文档的结尾,然后添加一个简单的文本。

My code add a new break page at the end of an existing document and then add a simple text.

这是你要找的吗?

查看我的代码。 ..

Have a look at my code...

 private static void AddTextOnNewPage(string docName, string text)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(docName, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                var breakPar = new Paragraph(
                                        new Run(
                                        new Break() { Type = BreakValues.Page }));

                mainPart.Document.Body.InsertAfter(breakPar, mainPart.Document.Body.LastChild);

                var textPar = new Paragraph(
                                            new Run(
                                                new Text(text)));

                mainPart.Document.Body.InsertAfter(textPar, mainPart.Document.Body.LastChild);

                mainPart.Document.Save();
            }
        }


这篇关于在一个存在的文件中写入新的单词页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆