InsertText() public méthode

Inserts a specified instance of System.String into a Novacode.DocX.Paragraph at a specified index position.
public InsertText ( int index, string value, bool trackChanges = false, Formatting formatting = null ) : void
index int The index position of the insertion.
value string The System.String to insert.
trackChanges bool Flag this insert as a change.
formatting Formatting The text formatting.
Résultat void
Exemple #1
0
        public virtual Paragraph InsertParagraph(int index, string text, bool trackChanges, Formatting formatting)
        {
            Paragraph newParagraph = new Paragraph(Document, new XElement(DocX.w + "p"), index);
            newParagraph.InsertText(0, text, trackChanges, formatting);

            Paragraph firstPar = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);

            if (firstPar != null)
            {
                XElement[] splitParagraph = HelperFunctions.SplitParagraph(firstPar, index - firstPar.startIndex);

                firstPar.Xml.ReplaceWith
                (
                    splitParagraph[0],
                    newParagraph.Xml,
                    splitParagraph[1]
                );
            }

            else
                Xml.Add(newParagraph);

            GetParent(newParagraph);

            return newParagraph;
        }