Hi,
Now I want to create a table with w:tblStyle to replace a paragraph, and the value of the w:tblStyle is from the w:pStyle of the paragraph which is replaced. But it didn't work. The next lines is code.
tblPr = new TableProperties();
tbl.AppendChild(tblPr);
TableBorders tblBorders = new TableBorders();
tblPr.TableBorders = tblBorders;
TopBorder top = new TopBorder();
top.Color = "auto";
top.Size = 4;
top.Space = 0;
top.Val = BorderValues.Single;
tblBorders.AppendChild(top);
ParagraphStyleId pStyle = p.Descendants<ParagraphStyleId>().FirstOrDefault(); // p is the replaced paragraph
if (null != pStyle && null != pStyle.Val)
{
string pStyleVal = pStyle.Val.Value; TableStyle tblStyle = new TableStyle();
tblStyle.Val = pStyleVal;
tblPr.TableStyle = tblStyle;
}
body.ReplaceChild(tbl, p);
There is a weird thing.The tblPr.TableStyle is not null after execute,but there is no w:tblStyle tag in the document. Give me a hand please!Thanks!!