We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to use this method:table.PreviousSibling.Runs.Insert

I have this document,I hope according to table to find the front caption of the table,then add text in front of the caption.
test caption
There is table
I want to add text in front of test caption,like this:
add text test capion
There is table
I have a code
table.PreviousSibling,but table.PreviousSiblingtables is Node type,He doesn’t include Runs,can not use table.PreviousSibling.Runs.Insert(0, run)

Help me,thanks

Hi Yizheng,

Thanks for your interest in Aspose.Words.

First of all I would suggest you to please read the following article to understand the structure of Nodes in Aspose.Words’ DOM:

Secondly, you can use the following code snippet to achieve this:

Document doc = new Document(@"C:\Temp\Source+file.docx");
Table tab = doc.FirstSection.Body.Tables[0];
Paragraph targetPara = tab.PreviousSibling as Paragraph;
Run run = new Run(doc, "add text ");
run.Font.Color = Color.Red;
targetPara.Runs.Insert(0, run);

I hope, this helps.

Best regards,