Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c#windows应用程序中使用spire.doc dll更改.doc文档所有段落的字体大小_C#_Winforms_Fonts - Fatal编程技术网

如何在c#windows应用程序中使用spire.doc dll更改.doc文档所有段落的字体大小

如何在c#windows应用程序中使用spire.doc dll更改.doc文档所有段落的字体大小,c#,winforms,fonts,C#,Winforms,Fonts,在我的应用程序中,我需要加载.doc应用程序以更改字体大小。它只适用于单个段落,但当我需要时 要更改整个段落的字体大小,并非所有段落都适用 我试过下面的方法 Section s = document.Sections[0]; int i = s.Paragraphs.Count; ParagraphStyle style = new ParagraphStyle(document); for (int j = 0; j &

在我的应用程序中,我需要加载.doc应用程序以更改字体大小。它只适用于单个段落,但当我需要时

要更改整个段落的字体大小,并非所有段落都适用

我试过下面的方法

Section s = document.Sections[0];
            int i = s.Paragraphs.Count;
            ParagraphStyle style = new ParagraphStyle(document);

            for (int j = 0; j < i; j++)
            {              
                Spire.Doc.Documents.Paragraph p = s.Paragraphs[j];

                style.CharacterFormat.FontName = "Times New Roman";
                style.CharacterFormat.FontSize = 20;
                document.Styles.Add(style);
                p.ApplyStyle(style.Name);
            }
Section s=document.Sections[0];
int i=s.Count;
段落样式=新段落样式(文档);
对于(int j=0;j
以上内容不起作用,我如何更改整个文档中所有段落的字体大小,如果我在循环中出错,请任何人告诉我


谢谢

它没有运行的原因是您没有设置
style.Name

您需要设置
style.Name
才能被
p.ApplyStyle(style.Name)识别

可能重复的@Berkay它不是可能的重复,而是完全重复。我已经看到Jhon第三次发布这个问题了。嗨,我没有找到任何问题,所以我一次又一次地发布