How to set a font format of paragraph before the table

How to set a font format of paragraph before the table
I have a code:
(Aspose.Words.Paragraph)table.PreviousSibling
but can not use like :ParagraphFormat.StyleName, ParagraphBreakFont.NameAscii
This is the source file:
test font format of caption
tabel
The target file:
test font format of caption
tabel

I want use this way:

p.ParagraphFormat.StyleName = "Test My StyleName";

p is paragraph

after set,the p.paragraphFormat.stylename is “Test My StyleName” ,but p style not change ,i notice that after the document was generated i found paragraph Format are still original formatted

Could u please explain me how to resolve the problem.

Thanks,

Hi Pooja,

Thanks for your inquiry.

In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.2.0) from here and let us know how it goes on your side. If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

I have tested the scenario and have not found the shared issue. Please find the input/output files in attachment.

Document doc = new Document(MyDir + "in.docx");

Table table = (Table) doc.GetChild(NodeType.Table, 0, true);
Paragraph para = (Paragraph) table.PreviousSibling;
para.ParagraphFormat.StyleName = "Heading 1";
doc.Save(MyDir + "out.docx");

Hi Pooja,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.