Word,C#Automation中产生的多余文本行 [英] Unwanted line of text produced in Word, C# Automation

查看:83
本文介绍了Word,C#Automation中产生的多余文本行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在空白的10pt行和另一行上带有社会评估"的行之间创建11pt字体的多余行.

I am creating an unwanted line of 11pt font between a blank 10pt line and another line with "Social Assessment" on it.

            //first line
            Word.Paragraph paragraph;
            paragraph = oDoc.Content.Paragraphs.Add(ref oMissing);
            Word.Range para = paragraph.Range;
            para.Font.Size = 10;
            para.Font.Name = "Arial";
            para.Font.Bold = 1;
            para.Text = "\r\n";
            paragraph.Format.SpaceAfter = 24;
            para.InsertParagraphAfter();
            para.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            
///////////////Here is the line of 10pt font

            //next line
            Word.Paragraph oPara1;
            oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
            Word.Range rng = oPara1.Range;
            rng.Font.Size = 14;
            rng.Font.Name = "Arial";
            rng.Font.Bold = 1;
            rng.Text = "SOCIAL ASSESSMENT";
            oPara1.Format.SpaceAfter = 24;    //24 pt spacing after paragraph.
            rng.InsertParagraphAfter();
            rng.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;




是什么原因引起的问题/如何解决?谢谢.




What is causing the problem/ how can I get rid of it? Thanks.

推荐答案

您正在使用多个段落:但是段落是用来分隔两个不同的块的.
请改用一个段落,并使用"para.Inlines.Add(new Run(" Hello));;"添加多行.
您也可以设置运行元素的样式.
You are using multiple paragraphs: But paragraphs are made to separate two different blocks.

Use one paragraph instead and add multiple lines with "para.Inlines.Add(new Run("Hello"));".
You can style the run element, too.


您好,请检查此链接:
Hi, Check this this link : Summarize C# Control Word Skills[^]


这篇关于Word,C#Automation中产生的多余文本行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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