I set 2 lines of text as “title1” style and 2 lines of text as “body1” style in word, but with the name that cannot get the style, this is code:
Debug.WriteLine(“style:” + paragraph.ParagraphFormat.Style.Name);
Output result:Normal
the result is “Normal”, the result I want to get is title1 or body1, how to solve it?
Testtitle1.docx (14.3 KB)
@lovecomputer Unfortunately, I cannot preproduce the problem on my side. The following code properly returns paragraph style names applied to paragraphs in the attached document:
Document doc = new Document(@"C:\Temp\in.docx");
foreach(Paragraph p in doc.FirstSection.Body.Paragraphs)
Console.WriteLine(p.ParagraphFormat.StyleName);
output is the following:
title1
title1
body1
body1
Normal