public override Table AppendTable(CreateTableParameters parameters) { Document.Styles.EnsureStyle(parameters.Style, StyleType.Table); var table = Table.Create(parameters, this); if (hostingParagraph == null) // i.e. this is the last document section { var lastParagraph = sectionParagraphs.LastOrDefault(); if (lastParagraph == null) { Xml.AddBeforeSelf(table.Xml); } else { lastParagraph.Xml.AddAfterSelf(table.Xml); } } else { Xml.Remove(); var newSectionLastParagraphXml = new XElement( XName.Get("p", Namespaces.w.NamespaceName), new XElement(XName.Get("pPr", Namespaces.w.NamespaceName), Xml)); hostingParagraph.Xml.AddAfterSelf(newSectionLastParagraphXml); hostingParagraph.Xml.AddAfterSelf(table.Xml); var newSectionLastParagraph = new Paragraph(newSectionLastParagraphXml, this); hostingParagraph = newSectionLastParagraph; sectionParagraphs.Add(newSectionLastParagraph); } return(table); }
public virtual Table AppendTable(CreateTableParameters parameters) { Document.Styles.EnsureStyle(parameters.Style, StyleType.Table); var table = Table.Create(parameters, this); Xml.Add(table.Xml); return(table); }