Xceed.Words.NET Represents a border of a table or table cell Axis base class ID of this Axis Return true if this axis is visible Axis xml element Represents Category Axes Represents Values Axes This element contains the 2-D bar or column series on this chart. 21.2.2.16 barChart (Bar Charts) Specifies the possible directions for a bar chart. Specifies the possible groupings for a bar chart. Specifies that its contents contain a percentage between 0% and 500%. Specifies the possible directions for a bar chart. 21.2.3.3 ST_BarDir (Bar Direction) Specifies the possible groupings for a bar chart. 21.2.3.4 ST_BarGrouping (Bar Grouping) Represents every Chart in this document. The xml representation of this chart Chart's series Return maximum count of series Chart's legend. If legend doesn't exist property is null. Represents the category axis Represents the values axis Represents existing the axis Get or set 3D view for this chart Specifies how blank cells shall be plotted on a chart Create an Chart for this document Add a new series to this chart Add standart legend to the chart. Add a legend with parameters to the chart. Remove the legend from the chart. An abstract method which creates the current chart xml Represents a chart series Series xml element Represents a chart legend More: http://msdn.microsoft.com/ru-ru/library/cc845123.aspx Specifies that other chart elements shall be allowed to overlap this chart element Specifies the possible positions for a legend Legend xml element ECMA-376, page 3840 21.2.2.132 overlay (Overlay) Specifies the possible positions for a legend. 21.2.3.24 ST_LegendPos (Legend Position) Specifies the possible ways to display blanks. 21.2.3.10 ST_DispBlanksAs (Display Blanks As) This element contains the 2-D line chart series. 21.2.2.97 lineChart (Line Charts) Specifies the kind of grouping for a column, line, or area chart. Specifies the kind of grouping for a column, line, or area chart. 21.2.2.76 grouping (Grouping) This element contains the 2-D pie series for this chart. 21.2.2.141 pieChart (Pie Charts) Get value from XElement and convert it to enum Enum type Convert value to xml string and set it into XElement Enum type Return xml string for this value Enum type This attribute applied to enum's fields for definition their's real xml names in DocX file. public enum MyEnum { [XmlName("one")] // This means, that xml element has 'val="one"' ValueOne, [XmlName("two")] // This means, that xml element has 'val="two"' ValueTwo } Real xml name Returns a list of all Paragraphs inside this container. Load a document. using (DocX document = DocX.Load(@"Test.docx")) { // All Paragraphs in this document. ]]> documentParagraphs = document.Paragraphs; // Make sure this document contains at least one Table. if (document.Tables.Count() > 0) { // Get the first Table in this document. Table t = document.Tables[0]; // All Paragraphs in this Table. ]]> tableParagraphs = t.Paragraphs; // Make sure this Table contains at least one Row. if (t.Rows.Count() > 0) { // Get the first Row in this document. Row r = t.Rows[0]; // All Paragraphs in this Row. ]]> rowParagraphs = r.Paragraphs; // Make sure this Row contains at least one Cell. if (r.Cells.Count() > 0) { // Get the first Cell in this document. Cell c = r.Cells[0]; // All Paragraphs in this Cell. ]]> cellParagraphs = c.Paragraphs; } } } // Save all changes to this document. document.Save(); }// Release this document from memory. Sets the Direction of content. Direction either LeftToRight or RightToLeft Set the Direction of content in a Paragraph to RightToLeft. // Load a document. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first Paragraph from this document. Paragraph p = document.InsertParagraph(); // Set the Direction of this Paragraph. p.Direction = Direction.RightToLeft; // Make sure the document contains at lest one Table. if (document.Tables.Count() > 0) { // Get the first Table from this document. Table t = document.Tables[0]; /* * Set the direction of the entire Table. * Note: The same function is available at the Row and Cell level. */ t.SetDirection(Direction.RightToLeft); } // Save all changes to this document. document.Save(); }// Release this document from memory. Find all unique instances of the given Regex Pattern, returning the list of the unique strings found The value to find. A Func who accepts the matching regex search group value and passes it to this to return the replacement string. Enable or disable the track changes. The Regex options. Remove empty paragraph Removes paragraph at specified position Index of paragraph to remove True if paragraph removed Removes a paragraph The paragraph to remove True if paragraph removed The name of this CustomProperty. The value of this CustomProperty. Create a new CustomProperty to hold a string. The name of this CustomProperty. The value of this CustomProperty. Create a new CustomProperty to hold an int. The name of this CustomProperty. The value of this CustomProperty. Create a new CustomProperty to hold a double. The name of this CustomProperty. The value of this CustomProperty. Create a new CustomProperty to hold a DateTime. The name of this CustomProperty. The value of this CustomProperty. Create a new CustomProperty to hold a bool. The name of this CustomProperty. The value of this CustomProperty. Represents a field of type document property. This field displays the value stored in a custom property. The custom property to display. If this document does not contain a /word/styles.xml add the default one generated by Microsoft Word. Create and return a cell of a table Add the default numbering.xml if it is missing from this document Represents a Hyperlink in a document. Change the Text of a Hyperlink. Change the Text of a Hyperlink. // Create a document. using (DocX document = DocX.Load(@"Test.docx")) { // Get all of the hyperlinks in this document List<Hyperlink> hyperlinks = document.Hyperlinks; // Change the first hyperlinks text and Uri Hyperlink h0 = hyperlinks[0]; h0.Text = "DocX"; h0.Uri = new Uri("http://docx.codeplex.com"); // Save this document. document.Save(); } Change the Uri of a Hyperlink. Change the Uri of a Hyperlink. hyperlinks = document.Hyperlinks; // Change the first hyperlinks text and Uri Hyperlink h0 = hyperlinks[0]; h0.Text = "DocX"; h0.Uri = new Uri("http://docx.codeplex.com"); // Save this document. document.Save(); } ]]> Remove a Hyperlink from this Paragraph only. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add a hyperlink to this document. Hyperlink h = document.AddHyperlink("link", new Uri("http://www.google.com")); // Add a Paragraph to this document and insert the hyperlink Paragraph p1 = document.InsertParagraph(); p1.Append("This is a cool ").AppendHyperlink(h).Append(" ."); /* * Remove the hyperlink from this Paragraph only. * Note a reference to the hyperlink will still exist in the document and it can thus be reused. */ p1.Hyperlinks[0].Remove(); // Add a new Paragraph to this document and reuse the hyperlink h. Paragraph p2 = document.InsertParagraph(); p2.Append("This is the same cool ").AppendHyperlink(h).Append(" ."); document.Save(); }// Release this document from memory. Represents a List in a document. This is a list of paragraphs that will be added to the document when the list is inserted into the document. The paragraph needs a numPr defined to be in this items collection. The numId used to reference the list settings in the numbering.xml The ListItemType (bullet or numbered) of the list. Adds an item to the list. Throws an InvalidOperationException if the item cannot be added to the list. Determine if it is able to add the item to the list Return true if AddItem(...) will succeed with the given paragraph. Get the abstractNum definition for the given numId The numId on the pPr element XElement representing the requested abstractNum Method to determine the last numId for a list element. Also useful for determining the next numId to use for inserting a new list element into the document. 0 if there are no elements in the list already. Increment the return for the next valid value of a new list element. Method to determine the last abstractNumId for a list element. Also useful for determining the next abstractNumId to use for inserting a new list element into the document. -1 if there are no elements in the list already. Increment the return for the next valid value of a new list element. Represents a table of contents in the document All DocX types are derived from DocXElement. This class contains properties which every element of a DocX must contain. This is the actual Xml that gives this element substance. For example, a Paragraphs Xml might look something like the following

Hello World!

This is a reference to the DocX object that this element belongs to. Every DocX element is connected to a document. Store both the document and xml so that they can be accessed by derived types. The document that this element belongs to. The Xml that gives this element substance This class provides functions for inserting new DocXElements before or after the current DocXElement. Only certain DocXElements can support these functions without creating invalid documents, at the moment these are Paragraphs and Table. Represents a Table in a document. The custom design\style to apply to this table. Returns a list of all Paragraphs inside this container. Returns a list of all Pictures in a Table. Returns a list of all Pictures in a Table. pictures = t.Pictures; // Save this document. document.Save(); } ]]> Get all of the Hyperlinks in this Table. Get all of the Hyperlinks in this Table. // Create a document. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first Table in this document. Table t = document.Tables[0]; // Get a list of all Hyperlinks in this Table. List<Hyperlink> hyperlinks = t.Hyperlinks; // Save this document. document.Save(); } Returns the number of rows in this table. Returns the number of columns in this table. Returns a list of rows in this table. Auto size this table according to some rule. The design\style to apply to this table. Returns the index of this Table. Replace the first table in this document with a new Table. // Load a document into memory. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first Table in this document. Table t = document.Tables[0]; // Get the character index of Table t in this document. int index = t.Index; // Remove Table t. t.Remove(); // Insert a new Table at the original index of Table t. Table newTable = document.InsertTable(index, 4, 4); // Set the design of this new Table, so that we can see it. newTable.Design = TableDesign.LightShadingAccent1; // Save all changes made to the document. document.Save(); } // Release this document from memory. The custom design/style to apply to this table. Gets or sets the value of the Table Caption (Alternate Text Title) of this table. Gets or sets the value of the Table Description (Alternate Text Description) of this table. Merge cells in given column starting with startRow and ending with endRow. Set the direction of all content in this Table. (Left to Right) or (Right to Left) Set the content direction for all content in a table to RightToLeft. // Load a document. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first table in a document. Table table = document.Tables[0]; // Set the content direction for all content in this table to RightToLeft. table.SetDirection(Direction.RightToLeft); // Save all changes made to this document. document.Save(); } Remove this Table from this document. Remove the first Table from this document. // Load a document into memory. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first Table in this document. Table t = d.Tables[0]; // Remove this Table. t.Remove(); // Save all changes made to the document. document.Save(); } // Release this document from memory. Insert a row at the end of this table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Insert a new row at the end of this table. Row row = table.InsertRow(); // Loop through each cell in this new row. foreach (Cell c in row.Cells) { // Set the text of each new cell to "Hello". c.Paragraphs[0].InsertText("Hello", false); } // Save the document to a new file. document.SaveAs(@"C:\Example\Test2.docx"); }// Release this document from memory. A new row. Insert a copy of a row at the end of this table. A new row. Insert a column to the right of a Table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first Table in this document. Table table = document.Tables[0]; // Insert a new column to this right of this table. table.InsertColumn(); // Set the new columns text to "Row no." table.Rows[0].Cells[table.ColumnCount - 1].Paragraph.InsertText("Row no.", false); // Loop through each row in the table. for (int i = 1; i < table.Rows.Count; i++) { // The current row. Row row = table.Rows[i]; // The cell in this row that belongs to the new column. Cell cell = row.Cells[table.ColumnCount - 1]; // The first Paragraph that this cell houses. Paragraph p = cell.Paragraphs[0]; // Insert this rows index. p.InsertText(i.ToString(), false); } document.Save(); }// Release this document from memory. Remove the last row from this Table. Remove the last row from a Table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Remove the last row from this table. table.RemoveRow(); // Save the document. document.Save(); }// Release this document from memory. Remove a row from this Table. The row to remove. Remove the first row from a Table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Remove the first row from this table. table.RemoveRow(0); // Save the document. document.Save(); }// Release this document from memory. Remove the last column for this Table. Remove the last column from a Table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Remove the last column from this table. table.RemoveColumn(); // Save the document. document.Save(); }// Release this document from memory. Remove a column from this Table. The column to remove. Remove the first column from a Table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Remove the first column from this table. table.RemoveColumn(0); // Save the document. document.Save(); }// Release this document from memory. Insert a row into this table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first table in this document. Table table = document.Tables[0]; // Insert a new row at index 1 in this table. Row row = table.InsertRow(1); // Loop through each cell in this new row. foreach (Cell c in row.Cells) { // Set the text of each new cell to "Hello". c.Paragraphs[0].InsertText("Hello", false); } // Save the document to a new file. document.SaveAs(@"C:\Example\Test2.docx"); }// Release this document from memory. Index to insert row at. A new Row Insert a copy of a row into this table. Row to copy and insert. Index to insert row at. True to clone everithing, False to clone cell structure only. A new Row Insert a column into a table. The index to insert the column at. The side in which you wish to place the colum : True for right, false for left. Insert a column to the left of a table. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Get the first Table in this document. Table table = document.Tables[0]; // Insert a new column to this left of this table. table.InsertColumn(0, false); // Set the new columns text to "Row no." table.Rows[0].Cells[table.ColumnCount - 1].Paragraph.InsertText("Row no.", false); // Loop through each row in the table. for (int i = 1; i < table.Rows.Count; i++) { // The current row. Row row = table.Rows[i]; // The cell in this row that belongs to the new column. Cell cell = row.Cells[table.ColumnCount - 1]; // The first Paragraph that this cell houses. Paragraph p = cell.Paragraphs[0]; // Insert this rows index. p.InsertText(i.ToString(), false); } document.Save(); }// Release this document from memory. Insert a page break before a Table. Insert a Table and a Paragraph into a document with a page break between them. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p1 = document.InsertParagraph("Paragraph", false); // Insert a new Table. Table t1 = document.InsertTable(2, 2); t1.Design = TableDesign.LightShadingAccent1; // Insert a page break before this Table. t1.InsertPageBreakBeforeSelf(); // Save this document. document.Save(); }// Release this document from memory. Insert a page break after a Table. Insert a Table and a Paragraph into a document with a page break between them. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Table. Table t1 = document.InsertTable(2, 2); t1.Design = TableDesign.LightShadingAccent1; // Insert a page break after this Table. t1.InsertPageBreakAfterSelf(); // Insert a new Paragraph. Paragraph p1 = document.InsertParagraph("Paragraph", false); // Save this document. document.Save(); }// Release this document from memory. Insert a new Table before this Table, this Table can be from this document or another document. The Table t to be inserted A new Table inserted before this Table. Insert a new Table before this Table. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Table in document b. Table t2 = documentB.Tables[0]; // Insert the Table from document a before this Table. Table newTable = t2.InsertTableBeforeSelf(t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Table into this document before this Table. The number of rows this Table should have. The number of columns this Table should have. A new Table inserted before this Table. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { //Insert a Table into this document. Table t = document.InsertTable(2, 2); t.Design = TableDesign.LightShadingAccent1; t.Alignment = Alignment.center; // Insert a new Table before this Table. Table newTable = t.InsertTableBeforeSelf(2, 2); newTable.Design = TableDesign.LightShadingAccent2; newTable.Alignment = Alignment.center; // Save all changes made to this document. document.Save(); }// Release this document from memory. Insert a new Table after this Table, this Table can be from this document or another document. The Table t to be inserted A new Table inserted after this Table. Insert a new Table after this Table. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Table in document b. Table t2 = documentB.Tables[0]; // Insert the Table from document a after this Table. Table newTable = t2.InsertTableAfterSelf(t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Table into this document after this Table. The number of rows this Table should have. The number of columns this Table should have. A new Table inserted before this Table. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { //Insert a Table into this document. Table t = document.InsertTable(2, 2); t.Design = TableDesign.LightShadingAccent1; t.Alignment = Alignment.center; // Insert a new Table after this Table. Table newTable = t.InsertTableAfterSelf(2, 2); newTable.Design = TableDesign.LightShadingAccent2; newTable.Alignment = Alignment.center; // Save all changes made to this document. document.Save(); }// Release this document from memory. Insert a Paragraph before this Table, this Paragraph may have come from the same or another document. The Paragraph to insert. The Paragraph now associated with this document. Take a Paragraph from document a, and insert it into document b before this Table. // Place holder for a Paragraph. Paragraph p; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first paragraph from this document. p = documentA.Paragraphs[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Table in document b. Table t = documentB.Tables[0]; // Insert the Paragraph from document a before this Table. Paragraph newParagraph = t.InsertParagraphBeforeSelf(p); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Paragraph before this Table. The initial text for this new Paragraph. A new Paragraph inserted before this Table. Insert a new Paragraph before the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); t.InsertParagraphBeforeSelf("I was inserted before the next Table."); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph before this Table. The initial text for this new Paragraph. Should this insertion be tracked as a change? A new Paragraph inserted before this Table. Insert a new paragraph before the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); t.InsertParagraphBeforeSelf("I was inserted before the next Table.", false); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph before this Table. The initial text for this new Paragraph. Should this insertion be tracked as a change? The formatting to apply to this insertion. A new Paragraph inserted before this Table. Insert a new paragraph before the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); Formatting boldFormatting = new Formatting(); boldFormatting.Bold = true; t.InsertParagraphBeforeSelf("I was inserted before the next Table.", false, boldFormatting); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a Paragraph after this Table, this Paragraph may have come from the same or another document. The Paragraph to insert. The Paragraph now associated with this document. Take a Paragraph from document a, and insert it into document b after this Table. // Place holder for a Paragraph. Paragraph p; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first paragraph from this document. p = documentA.Paragraphs[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Table in document b. Table t = documentB.Tables[0]; // Insert the Paragraph from document a after this Table. Paragraph newParagraph = t.InsertParagraphAfterSelf(p); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Paragraph after this Table. The initial text for this new Paragraph. Should this insertion be tracked as a change? The formatting to apply to this insertion. A new Paragraph inserted after this Table. Insert a new paragraph after the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); Formatting boldFormatting = new Formatting(); boldFormatting.Bold = true; t.InsertParagraphAfterSelf("I was inserted after the previous Table.", false, boldFormatting); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph after this Table. The initial text for this new Paragraph. Should this insertion be tracked as a change? A new Paragraph inserted after this Table. Insert a new paragraph after the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); t.InsertParagraphAfterSelf("I was inserted after the previous Table.", false); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph after this Table. The initial text for this new Paragraph. A new Paragraph inserted after this Table. Insert a new Paragraph after the first Table in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Table into this document. Table t = document.InsertTable(2, 2); t.InsertParagraphAfterSelf("I was inserted after the previous Table."); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Set a table border // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Insert a table into this document. Table t = document.InsertTable(3, 3); // Create a large blue border. Border b = new Border(BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Blue); // Set the tables Top, Bottom, Left and Right Borders to b. t.SetBorder(TableBorderType.Top, b); t.SetBorder(TableBorderType.Bottom, b); t.SetBorder(TableBorderType.Left, b); t.SetBorder(TableBorderType.Right, b); // Save the document. document.Save(); } The table border to set Border object to set the table border Get a table border The table border to get Deletes a cell in a row and shift the others to the left. index of the row where a cell will be removed. index of the cell to remove in the row. If the tblPr element doesent exist it is created, either way it is returned by this function. The tblPr element for this Table. Represents a single row in a Table. Calculates columns count in the row, taking spanned cells into account Returns the row.GridAfter => The number of deleted cells in a row. A list of Cells in this Row. Height in pixels. Minimum Height in pixels. Allow row to break across pages. Default value is True : Word will break the contents of the row across the pages. When False, the contents of the row will not be split across the pages; it will be entirely moved to the next page. Merge cells starting with startIndex and ending with endIndex. Width in pixels. LeftMargin in pixels. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Insert table into this document. Table t = document.InsertTable(3, 3); t.Design = TableDesign.TableGrid; // Get the center cell. Cell center = t.Rows[1].Cells[1]; // Insert some text so that we can see the effect of the Margins. center.Paragraphs[0].Append("Center Cell"); // Set the center cells Left, Margin to 10. center.MarginLeft = 25; // Save the document. document.Save(); } RightMargin in pixels. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Insert table into this document. Table t = document.InsertTable(3, 3); t.Design = TableDesign.TableGrid; // Get the center cell. Cell center = t.Rows[1].Cells[1]; // Insert some text so that we can see the effect of the Margins. center.Paragraphs[0].Append("Center Cell"); // Set the center cells Right, Margin to 10. center.MarginRight = 25; // Save the document. document.Save(); } TopMargin in pixels. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Insert table into this document. Table t = document.InsertTable(3, 3); t.Design = TableDesign.TableGrid; // Get the center cell. Cell center = t.Rows[1].Cells[1]; // Insert some text so that we can see the effect of the Margins. center.Paragraphs[0].Append("Center Cell"); // Set the center cells Top, Margin to 10. center.MarginTop = 25; // Save the document. document.Save(); } BottomMargin in pixels. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Insert table into this document. Table t = document.InsertTable(3, 3); t.Design = TableDesign.TableGrid; // Get the center cell. Cell center = t.Rows[1].Cells[1]; // Insert some text so that we can see the effect of the Margins. center.Paragraphs[0].Append("Center Cell"); // Set the center cells Top, Margin to 10. center.MarginBottom = 25; // Save the document. document.Save(); } Returns the Cell.GridSpan => How many cells are merged. Get a table cell border The table cell border to get Table Cell Border styles source: http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.tablecellborders.aspx Table Cell Border Types source: http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.tablecellborders.aspx Table Border Types source: http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.tableborders.aspx Change the caps style of text, for use with Append and AppendLine. No caps, make all characters are lowercase. All caps, make every character uppercase. Small caps, make all characters capital but with a small font size. Designs\Styles that can be applied to a table. How a Table should auto resize. Text alignment of a Paragraph. Align Paragraph to the left. Align Paragraph as centered. Align Paragraph to the right. (Justified) Align Paragraph to both the left and right margins, adding extra space between content as necessary. Paragraph edit types A ins is a tracked insertion A del is tracked deletion Custom property types. System.String System.DateTime System.Int32 System.Double System.Boolean Text types in a Run System.String System.String A text formatting. A text formatting. Text language This formatting will apply Bold. This formatting will apply Italic. This formatting will apply StrickThrough. The script that this formatting should be, normal, superscript or subscript. The Size of this text, must be between 0 and 1638. Percentage scale must be one of the following values 200, 150, 100, 90, 80, 66, 50 or 33. The Kerning to apply to this text must be one of the following values 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72. Text position must be in the range (-1585 - 1585). Text spacing must be in the range (-1585 - 1585). The colour of the text. Highlight colour. Shading color. The Underline style that this formatting applies. The underline colour. Misc settings. Is this text hidden or visible. Capitalization style. The font Family of this formatting. Returns a cloned instance of Formatting. Represents an Image embedded in a document. A unique id which identifies this Image. Returns the id of this Image. Returns the name of the image file. Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append. Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append. using (DocX document = DocX.Create("Test.docx")) { // Add an image to the document. Image i = document.AddImage(@"Image.jpg"); // Create a picture i.e. (A custom view of an image) Picture p = i.CreatePicture(); p.FlipHorizontal = true; p.Rotation = 10; // Create a new Paragraph. Paragraph par = document.InsertParagraph(); // Append content to the Paragraph. par.Append("Here is a cool picture") .AppendPicture(p) .Append(" don't you think so?"); // Save all changes made to this document. document.Save(); } Add an image to a document with specific height and width, create a custom view of that image (picture) and then insert it into a Paragraph using append. Represents a Picture in this document, a Picture is a customized view of an Image. A unique id that identifies an Image embedded in this document. Flip this Picture Horizontally. Flip this Picture Vertically. The rotation in degrees of this image, actual value = value % 360 Gets or sets the name of this Image. Gets or sets the description for this Image. Returns the name of the image file for the picture. Gets or sets the Width of this Image. Gets or sets the Width of this Image (in Inches) Gets or sets the height of this Image. Gets or sets the Height of this Image (in Inches) Wraps an XElement as an Image The XElement i to wrap Remove this Picture from this document. Set the shape of this Picture to one in the BasicShapes enumeration. A shape from the BasicShapes enumeration. Set the shape of this Picture to one in the RectangleShapes enumeration. A shape from the RectangleShapes enumeration. Set the shape of this Picture to one in the BlockArrowShapes enumeration. A shape from the BlockArrowShapes enumeration. Set the shape of this Picture to one in the EquationShapes enumeration. A shape from the EquationShapes enumeration. Set the shape of this Picture to one in the FlowchartShapes enumeration. A shape from the FlowchartShapes enumeration. Set the shape of this Picture to one in the StarAndBannerShapes enumeration. A shape from the StarAndBannerShapes enumeration. Set the shape of this Picture to one in the CalloutShapes enumeration. A shape from the CalloutShapes enumeration. Represents a document paragraph. Returns a list of all Pictures in a Paragraph. Returns a list of all Pictures in a Paragraph. pictures = p.Pictures; // Save this document. document.Save(); } ]]> Returns a list of Hyperlinks in this Paragraph. // Create a document. using (DocX document = DocX.Load(@"Test.docx")) { // Get the first Paragraph in this document. Paragraph p = document.Paragraphs[0]; // Get all of the hyperlinks in this Paragraph. ]]> hyperlinks = paragraph.Hyperlinks; // Change the first hyperlinks text and Uri Hyperlink h0 = hyperlinks[0]; h0.Text = "DocX"; h0.Uri = new Uri("http://docx.codeplex.com"); // Save this document. document.Save(); } The style name of the paragraph. Returns a list of field type DocProperty in this document. Gets or Sets the Direction of content in this Paragraph. Create a Paragraph with content that flows right to left. Default is left to right. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Create a new Paragraph with the text "Hello World". Paragraph p = document.InsertParagraph("Hello World."); // Make this Paragraph flow right to left. Default is left to right. p.Direction = Direction.RightToLeft; // Save all changes made to this document. document.Save(); } Get or set the indentation of the first line of this Paragraph. Indent only the first line of a Paragraph. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Create a new Paragraph. Paragraph p = document.InsertParagraph("Line 1\nLine 2\nLine 3"); // Indent only the first line of the Paragraph. p.IndentationFirstLine = 2.0f; // Save all changes made to this document. document.Save(); } Get or set the indentation of all but the first line of this Paragraph. Indent all but the first line of a Paragraph. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Create a new Paragraph. Paragraph p = document.InsertParagraph("Line 1\nLine 2\nLine 3"); // Indent all but the first line of the Paragraph. p.IndentationHanging = 1.0f; // Save all changes made to this document. document.Save(); } Set the before indentation in cm for this Paragraph. // Indent an entire Paragraph from the left. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Create a new Paragraph. Paragraph p = document.InsertParagraph("Line 1\nLine 2\nLine 3"); // Indent this entire Paragraph from the left. p.IndentationBefore = 2.0f; // Save all changes made to this document. document.Save(); } Set the after indentation in cm for this Paragraph. // Indent an entire Paragraph from the right. // Create a new document. using (DocX document = DocX.Create("Test.docx")) { // Create a new Paragraph. Paragraph p = document.InsertParagraph("Line 1\nLine 2\nLine 3"); // Make the content of this Paragraph flow right to left. p.Direction = Direction.RightToLeft; // Indent this entire Paragraph from the right. p.IndentationAfter = 2.0f; // Save all changes made to this document. document.Save(); } Gets or set this Paragraphs text alignment. Gets the text value of this Paragraph. Gets the formatted text value of this Paragraph. For use with Append() and AppendLine() This Paragraph in curent culture Add a new Paragraph with russian text to this document and then set language of text to local culture. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph with russian text and set curent local culture to it. Paragraph p = document.InsertParagraph("Привет мир!").CurentCulture(); // Save this document. document.Save(); } Returns table following the paragraph. Null if the following element isn't table. Indicates if this paragraph is a list element Get the indentation level of the list item Insert a new Table before this Paragraph, this Table can be from this document or another document. The Table t to be inserted. A new Table inserted before this Paragraph. Insert a new Table before this Paragraph. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Paragraph in document b. Paragraph p2 = documentB.Paragraphs[0]; // Insert the Table from document a before this Paragraph. Table newTable = p2.InsertTableBeforeSelf(t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Table into this document before this Paragraph. The number of rows this Table should have. The number of columns this Table should have. A new Table inserted before this Paragraph. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { //Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("Hello World", false); // Insert a new Table before this Paragraph. Table newTable = p.InsertTableBeforeSelf(2, 2); newTable.Design = TableDesign.LightShadingAccent2; newTable.Alignment = Alignment.center; // Save all changes made to this document. document.Save(); }// Release this document from memory. Insert a new Table after this Paragraph. The Table t to be inserted. A new Table inserted after this Paragraph. Insert a new Table after this Paragraph. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Paragraph in document b. Paragraph p2 = documentB.Paragraphs[0]; // Insert the Table from document a after this Paragraph. Table newTable = p2.InsertTableAfterSelf(t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Table into this document after this Paragraph. The number of rows this Table should have. The number of columns this Table should have. A new Table inserted after this Paragraph. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { //Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("Hello World", false); // Insert a new Table after this Paragraph. Table newTable = p.InsertTableAfterSelf(2, 2); newTable.Design = TableDesign.LightShadingAccent2; newTable.Alignment = Alignment.center; // Save all changes made to this document. document.Save(); }// Release this document from memory. Replaces an existing Picture with a new Picture. The picture object to be replaced. The picture object that should be inserted instead of . The new object that replaces the old one. Insert a Paragraph before this Paragraph, this Paragraph may have come from the same or another document. The Paragraph to insert. The Paragraph now associated with this document. Take a Paragraph from document a, and insert it into document b before this Paragraph. // Place holder for a Paragraph. Paragraph p; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first paragraph from this document. p = documentA.Paragraphs[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Paragraph in document b. Paragraph p2 = documentB.Paragraphs[0]; // Insert the Paragraph from document a before this Paragraph. Paragraph newParagraph = p2.InsertParagraphBeforeSelf(p); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Paragraph before this Paragraph. The initial text for this new Paragraph. A new Paragraph inserted before this Paragraph. Insert a new paragraph before the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); p.InsertParagraphBeforeSelf("I was inserted before the next Paragraph."); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph before this Paragraph. The initial text for this new Paragraph. Should this insertion be tracked as a change? A new Paragraph inserted before this Paragraph. Insert a new paragraph before the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); p.InsertParagraphBeforeSelf("I was inserted before the next Paragraph.", false); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph before this Paragraph. The initial text for this new Paragraph. Should this insertion be tracked as a change? The formatting to apply to this insertion. A new Paragraph inserted before this Paragraph. Insert a new paragraph before the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); Formatting boldFormatting = new Formatting(); boldFormatting.Bold = true; p.InsertParagraphBeforeSelf("I was inserted before the next Paragraph.", false, boldFormatting); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a page break before a Paragraph. Insert 2 Paragraphs into a document with a page break between them. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p1 = document.InsertParagraph("Paragraph 1", false); // Insert a new Paragraph. Paragraph p2 = document.InsertParagraph("Paragraph 2", false); // Insert a page break before Paragraph two. p2.InsertPageBreakBeforeSelf(); // Save this document. document.Save(); }// Release this document from memory. Insert a page break after a Paragraph. Insert 2 Paragraphs into a document with a page break between them. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p1 = document.InsertParagraph("Paragraph 1", false); // Insert a page break after this Paragraph. p1.InsertPageBreakAfterSelf(); // Insert a new Paragraph. Paragraph p2 = document.InsertParagraph("Paragraph 2", false); // Save this document. document.Save(); }// Release this document from memory. This function inserts a hyperlink into a Paragraph at a specified character index. The index to insert at. The hyperlink to insert. The Paragraph with the Hyperlink inserted at the specified index. Remove the Hyperlink at the provided index. The first hyperlink is at index 0. Using a negative index or an index greater than the index of the last hyperlink will cause an ArgumentOutOfRangeException() to be thrown. The index of the hyperlink to be removed. // Crete a new document. using (DocX document = DocX.Create("Test.docx")) { // Add a Hyperlink into this document. Hyperlink h = document.AddHyperlink("link", new Uri("http://www.google.com")); // Insert a new Paragraph into the document. Paragraph p1 = document.InsertParagraph("AC"); // Insert the hyperlink into this Paragraph. p1.InsertHyperlink(1, h); Assert.IsTrue(p1.Text == "AlinkC"); // Make sure the hyperlink was inserted correctly; // Remove the hyperlink p1.RemoveHyperlink(0); Assert.IsTrue(p1.Text == "AC"); // Make sure the hyperlink was removed correctly; } Insert a Paragraph after this Paragraph, this Paragraph may have come from the same or another document. The Paragraph to insert. The Paragraph now associated with this document. Take a Paragraph from document a, and insert it into document b after this Paragraph. // Place holder for a Paragraph. Paragraph p; // Load document a. using (DocX documentA = DocX.Load(@"a.docx")) { // Get the first paragraph from this document. p = documentA.Paragraphs[0]; } // Load document b. using (DocX documentB = DocX.Load(@"b.docx")) { // Get the first Paragraph in document b. Paragraph p2 = documentB.Paragraphs[0]; // Insert the Paragraph from document a after this Paragraph. Paragraph newParagraph = p2.InsertParagraphAfterSelf(p); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Paragraph after this Paragraph. The initial text for this new Paragraph. Should this insertion be tracked as a change? The formatting to apply to this insertion. A new Paragraph inserted after this Paragraph. Insert a new paragraph after the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); Formatting boldFormatting = new Formatting(); boldFormatting.Bold = true; p.InsertParagraphAfterSelf("I was inserted after the previous Paragraph.", false, boldFormatting); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph after this Paragraph. The initial text for this new Paragraph. Should this insertion be tracked as a change? A new Paragraph inserted after this Paragraph. Insert a new paragraph after the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); p.InsertParagraphAfterSelf("I was inserted after the previous Paragraph.", false); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Insert a new Paragraph after this Paragraph. The initial text for this new Paragraph. A new Paragraph inserted after this Paragraph. Insert a new paragraph after the first Paragraph in this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a Paragraph into this document. Paragraph p = document.InsertParagraph("I am a Paragraph", false); p.InsertParagraphAfterSelf("I was inserted after the previous Paragraph."); // Save all changes made to this new document. document.Save(); }// Release this new document form memory. Remove this Paragraph from the document. Should this remove be tracked as a change? Remove a Paragraph from a document and track it as a change. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create and Insert a new Paragraph into this document. Paragraph p = document.InsertParagraph("Hello", false); // Remove the Paragraph and track this as a change. p.Remove(true); // Save all changes made to this document. document.Save(); }// Release this document from memory. Inserts a specified instance of System.String into a Xceed.Words.NET.DocX.Paragraph at a specified index position. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create a text formatting. Formatting f = new Formatting(); f.FontColor = Color.Red; f.Size = 30; // Iterate through the Paragraphs in this document. foreach (Paragraph p in document.Paragraphs) { // Insert the string "Start: " at the begining of every Paragraph and flag it as a change. p.InsertText("Start: ", true, f); } // Save all changes made to this document. document.Save(); }// Release this document from memory. Inserting tabs using the \t switch. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create a text formatting. Formatting f = new Formatting(); f.FontColor = Color.Red; f.Size = 30; // Iterate through the paragraphs in this document. foreach (Paragraph p in document.Paragraphs) { // Insert the string "\tEnd" at the end of every paragraph and flag it as a change. p.InsertText("\tEnd", true, f); } // Save all changes made to this document. document.Save(); }// Release this document from memory. The System.String to insert. Flag this insert as a change. The text formatting. Inserts a specified instance of System.String into a Xceed.Words.NET.DocX.Paragraph at a specified index position. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create a text formatting. Formatting f = new Formatting(); f.FontColor = Color.Red; f.Size = 30; // Iterate through the Paragraphs in this document. foreach (Paragraph p in document.Paragraphs) { // Insert the string "Start: " at the begining of every Paragraph and flag it as a change. p.InsertText(0, "Start: ", true, f); } // Save all changes made to this document. document.Save(); }// Release this document from memory. Inserting tabs using the \t switch. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create a text formatting. Formatting f = new Formatting(); f.FontColor = Color.Red; f.Size = 30; // Iterate through the paragraphs in this document. foreach (Paragraph p in document.Paragraphs) { // Insert the string "\tStart:\t" at the begining of every paragraph and flag it as a change. p.InsertText(0, "\tStart:\t", true, f); } // Save all changes made to this document. document.Save(); }// Release this document from memory. The index position of the insertion. The System.String to insert. Flag this insert as a change. The text formatting. For use with Append() and AppendLine() The CultureInfo for text This Paragraph in curent culture Add a new Paragraph with russian text to this document and then set language of text to local culture. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph with russian text and set specific culture to it. Paragraph p = document.InsertParagraph("Привет мир").Culture(CultureInfo.CreateSpecificCulture("ru-RU")); // Save this document. document.Save(); } Append text to this Paragraph. The text to append. This Paragraph with the new text appened. Add a new Paragraph to this document and then append some text to it. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph and Append some text to it. Paragraph p = document.InsertParagraph().Append("Hello World!!!"); // Save this document. document.Save(); } Append text to this Paragraph and apply the provided format The text to append. The format to use. This Paragraph with the new text appended. Add a new Paragraph to this document, append some text to it and apply the provided format. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Prepare format to use Formatting format = new Formatting(); format.Bold = true; format.Size = 18; format.FontColor = Color.Blue; // Insert a new Paragraph and append some text to it with the custom format Paragraph p = document.InsertParagraph().Append("Hello World!!!", format); // Save this document. document.Save(); } Append a hyperlink to a Paragraph. The hyperlink to append. The Paragraph with the hyperlink appended. Creates a Paragraph with some text and a hyperlink. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add a hyperlink to this document. Hyperlink h = document.AddHyperlink("Google", new Uri("http://www.google.com")); // Add a new Paragraph to this document. Paragraph p = document.InsertParagraph(); p.Append("My favourite search engine is "); p.AppendHyperlink(h); p.Append(", I think it's great."); // Save all changes made to this document. document.Save(); } Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append. The Picture to append. The Paragraph with the Picture now appended. Add an image to a document, create a custom view of that image (picture) and then insert it into a Paragraph using append. using (DocX document = DocX.Create("Test.docx")) { // Add an image to the document. Image i = document.AddImage(@"Image.jpg"); // Create a picture i.e. (A custom view of an image) Picture p = i.CreatePicture(); p.FlipHorizontal = true; p.Rotation = 10; // Create a new Paragraph. Paragraph par = document.InsertParagraph(); // Append content to the Paragraph. par.Append("Here is a cool picture") .AppendPicture(p) .Append(" don't you think so?"); // Save all changes made to this document. document.Save(); } Add an equation to a document. The Equation to append. The Paragraph with the Equation now appended. Add an equation to a document. using (DocX document = DocX.Create("Test.docx")) { // Add an equation to the document. document.AddEquation("x=y+z"); // Save all changes made to this document. document.Save(); } Insert a Picture into a Paragraph at the given text index. If not index is provided defaults to 0. The Picture to insert. The text index to insert at. The modified Paragraph. Load test document. using (DocX document = DocX.Create("Test.docx")) { // Add Headers and Footers into this document. document.AddHeaders(); document.AddFooters(); document.DifferentFirstPage = true; document.DifferentOddAndEvenPages = true; // Add an Image to this document. Xceed.Words.NET.Image img = document.AddImage(directory_documents + "purple.png"); // Create a Picture from this Image. Picture pic = img.CreatePicture(); // Main document. Paragraph p0 = document.InsertParagraph("Hello"); p0.InsertPicture(pic, 3); // Header first. Paragraph p1 = document.Headers.first.InsertParagraph("----"); p1.InsertPicture(pic, 2); // Header odd. Paragraph p2 = document.Headers.odd.InsertParagraph("----"); p2.InsertPicture(pic, 2); // Header even. Paragraph p3 = document.Headers.even.InsertParagraph("----"); p3.InsertPicture(pic, 2); // Footer first. Paragraph p4 = document.Footers.first.InsertParagraph("----"); p4.InsertPicture(pic, 2); // Footer odd. Paragraph p5 = document.Footers.odd.InsertParagraph("----"); p5.InsertPicture(pic, 2); // Footer even. Paragraph p6 = document.Footers.even.InsertParagraph("----"); p6.InsertPicture(pic, 2); // Save this document. document.Save(); } Add a new TabStopPosition in the current paragraph. Specifies the alignment of the Tab stop. Specifies the horizontal position of the tab stop. Specifies the character used to fill in the space created by a tab. The modified Paragraph. Append text on a new line to this Paragraph. The text to append. This Paragraph with the new text appened. Add a new Paragraph to this document and then append a new line with some text to it. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph and Append a new line with some text to it. Paragraph p = document.InsertParagraph().AppendLine("Hello World!!!"); // Save this document. document.Save(); } Append a new line to this Paragraph. This Paragraph with a new line appeneded. Add a new Paragraph to this document and then append a new line to it. // Load a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph and Append a new line with some text to it. Paragraph p = document.InsertParagraph().AppendLine(); // Save this document. document.Save(); } For use with Append() and AppendLine() This Paragraph with the last appended text bold. Append text to this Paragraph and then make it bold. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Bold").Bold() .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() This Paragraph with the last appended text italic. Append text to this Paragraph and then make it italic. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Italic").Italic() .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() A color to use on the appended text. This Paragraph with the last appended text colored. Append text to this Paragraph and then color it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Blue").Color(Color.Blue) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The underline style to use for the appended text. This Paragraph with the last appended text underlined. Append text to this Paragraph and then underline it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Underlined").UnderlineStyle(UnderlineStyle.doubleLine) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The font size to use for the appended text. This Paragraph with the last appended text resized. Append text to this Paragraph and then resize it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Big").FontSize(20) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The font to use for the appended text. This Paragraph with the last appended text's font changed. For use with Append() and AppendLine() The font to use for the appended text. This Paragraph with the last appended text's font changed. Append text to this Paragraph and then change its font. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Times new roman").Font(new FontFamily("Times new roman")) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The caps style to apply to the last appended text. This Paragraph with the last appended text's caps style changed. Append text to this Paragraph and then set it to full caps. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("Capitalized").CapsStyle(CapsStyle.caps) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The script style to apply to the last appended text. This Paragraph with the last appended text's script style changed. Append text to this Paragraph and then set it to superscript. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("superscript").Script(Script.superscript) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The highlight to apply to the last appended text. This Paragraph with the last appended text highlighted. Append text to this Paragraph and then highlight it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("highlighted").Highlight(Highlight.green) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The miscellaneous property to set. This Paragraph with the last appended text changed by a miscellaneous property. Append text to this Paragraph and then apply a miscellaneous property. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("outlined").Misc(Misc.outline) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The strike through style to used on the last appended text. This Paragraph with the last appended text striked. Append text to this Paragraph and then strike it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("striked").StrikeThrough(StrikeThrough.doubleStrike) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() The underline color to use, if no underline is set, a single line will be used. This Paragraph with the last appended text underlined in a color. Append text to this Paragraph and then underline it using a color. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("color underlined").UnderlineStyle(UnderlineStyle.dotted).UnderlineColor(Color.Orange) .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. For use with Append() and AppendLine() This Paragraph with the last appended text hidden. Append text to this Paragraph and then hide it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Insert a new Paragraph. Paragraph p = document.InsertParagraph(); p.Append("I am ") .Append("hidden").Hide() .Append(" I am not"); // Save this document. document.Save(); }// Release this document from memory. Append a field of type document property, this field will display the custom property cp, at the end of this paragraph. The custom property to display. The formatting to use for this text. Create, add and display a custom property in a document. // Load a document. using (DocX document = DocX.Create("CustomProperty_Add.docx")) { // Add a few Custom Properties to this document. document.AddCustomProperty(new CustomProperty("fname", "cathal")); document.AddCustomProperty(new CustomProperty("age", 24)); document.AddCustomProperty(new CustomProperty("male", true)); document.AddCustomProperty(new CustomProperty("newyear2012", new DateTime(2012, 1, 1))); document.AddCustomProperty(new CustomProperty("fav_num", 3.141592)); // Insert a new Paragraph and append a load of DocProperties. Paragraph p = document.InsertParagraph("fname: ") .AppendDocProperty(document.CustomProperties["fname"]) .Append(", age: ") .AppendDocProperty(document.CustomProperties["age"]) .Append(", male: ") .AppendDocProperty(document.CustomProperties["male"]) .Append(", newyear2012: ") .AppendDocProperty(document.CustomProperties["newyear2012"]) .Append(", fav_num: ") .AppendDocProperty(document.CustomProperties["fav_num"]); // Save the changes to the document. document.Save(); } Insert a field of type document property, this field will display the custom property cp, at the end of this paragraph. The custom property to display. if the changes are tracked. The formatting to use for this text. Create, add and display a custom property in a document. // Load a document using (DocX document = DocX.Create(@"Test.docx")) { // Create a custom property. CustomProperty name = new CustomProperty("name", "Cathal Coffey"); // Add this custom property to this document. document.AddCustomProperty(name); // Create a text formatting. Formatting f = new Formatting(); f.Bold = true; f.Size = 14; f.StrikeThrough = StrickThrough.strike; // Insert a new paragraph. Paragraph p = document.InsertParagraph("Author: ", false, f); // Insert a field of type document property to display the custom property name and track this change. p.InsertDocProperty(name, true, f); // Save all changes made to this document. document.Save(); }// Release this document from memory. Removes characters from a Xceed.Words.NET.DocX.Paragraph. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Iterate through the paragraphs foreach (Paragraph p in document.Paragraphs) { // Remove the first two characters from every paragraph p.RemoveText(0, 2, false); } // Save all changes made to this document. document.Save(); }// Release this document from memory. The position to begin deleting characters. The number of characters to delete Track changes Remove empty paragraph Removes characters from a Xceed.Words.NET.DocX.Paragraph. // Create a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Iterate through the paragraphs foreach (Paragraph p in document.Paragraphs) { // Remove all but the first 2 characters from this Paragraph. p.RemoveText(2, false); } // Save all changes made to this document. document.Save(); }// Release this document from memory. The position to begin deleting characters. Track changes Replaces all occurrences of a specified System.String in this instance, with another specified System.String. // Load a document using a relative filename. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // The formatting to match. Formatting matchFormatting = new Formatting(); matchFormatting.Size = 10; matchFormatting.Italic = true; matchFormatting.FontFamily = new FontFamily("Times New Roman"); // The formatting to apply to the inserted text. Formatting newFormatting = new Formatting(); newFormatting.Size = 22; newFormatting.UnderlineStyle = UnderlineStyle.dotted; newFormatting.Bold = true; // Iterate through the paragraphs in this document. foreach (Paragraph p in document.Paragraphs) { /* * Replace all instances of the string "wrong" with the string "right" and ignore case. * Each inserted instance of "wrong" should use the Formatting newFormatting. * Only replace an instance of "wrong" if it is Size 10, Italic and Times New Roman. * SubsetMatch means that the formatting must contain all elements of the match formatting, * but it can also contain additional formatting for example Color, UnderlineStyle, etc. * ExactMatch means it must not contain additional formatting. */ p.ReplaceText("wrong", "right", false, RegexOptions.IgnoreCase, newFormatting, matchFormatting, MatchFormattingOptions.SubsetMatch); } // Save all changes made to this document. document.Save(); }// Release this document from memory. A System.String to replace all occurrences of oldValue. A System.String to be replaced. A bitwise OR combination of RegexOption enumeration options. Track changes The formatting to apply to the text being inserted. The formatting that the text must match in order to be replaced. How should formatting be matched? True if the oldValue needs to be escaped, otherwise false. If it represents a valid RegEx pattern this should be false. True if RegEx-like replace should be performed, i.e. if newValue contains RegEx substitutions. Does not perform named-group substitutions (only numbered groups). Remove empty paragraph Find all instances of a string in this paragraph and return their indexes in a List. The string to find A list of indexes. Find all instances of Hello in this document and insert 'don't' in frount of them. // Load a document using (DocX document = DocX.Load(@"Test.docx")) { // Loop through the paragraphs in this document. foreach(Paragraph p in document.Paragraphs) { // Find all instances of 'go' in this paragraph. ]]> gos = document.FindAll("go"); /* * Insert 'don't' in frount of every instance of 'go' in this document to produce 'don't go'. * An important trick here is to do the inserting in reverse document order. If you inserted * in document order, every insert would shift the index of the remaining matches. */ gos.Reverse(); foreach (int index in gos) { p.InsertText(index, "don't ", false); } } // Save all changes made to this document. document.Save(); }// Release this document from memory. Find all instances of a string in this paragraph and return their indexes in a List. The string to find The options to use when finding a string match. A list of indexes. Find all instances of Hello in this document and insert 'don't' in frount of them. // Load a document using (DocX document = DocX.Load(@"Test.docx")) { // Loop through the paragraphs in this document. foreach(Paragraph p in document.Paragraphs) { // Find all instances of 'go' in this paragraph (Ignore case). ]]> gos = document.FindAll("go", RegexOptions.IgnoreCase); /* * Insert 'don't' in frount of every instance of 'go' in this document to produce 'don't go'. * An important trick here is to do the inserting in reverse document order. If you inserted * in document order, every insert would shift the index of the remaining matches. */ gos.Reverse(); foreach (int index in gos) { p.InsertText(index, "don't ", false); } } // Save all changes made to this document. document.Save(); }// Release this document from memory. Find all unique instances of the given Regex Pattern Insert a PageNumber place holder into a Paragraph. This place holder should only be inserted into a Header or Footer Paragraph. Word will not automatically update this field if it is inserted into a document level Paragraph. The PageNumberFormat can be normal: (1, 2, ...) or Roman: (I, II, ...) The text index to insert this PageNumber place holder at. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Add Headers to the document. document.AddHeaders(); // Get the default Header. Header header = document.Headers.odd; // Insert a Paragraph into the Header. Paragraph p0 = header.InsertParagraph("Page ( of )"); // Insert place holders for PageNumber and PageCount into the Header. // Word will replace these with the correct value for each Page. p0.InsertPageNumber(PageNumberFormat.normal, 6); p0.InsertPageCount(PageNumberFormat.normal, 11); // Save the document. document.Save(); } Append a PageNumber place holder onto the end of a Paragraph. The PageNumberFormat can be normal: (1, 2, ...) or Roman: (I, II, ...) // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Add Headers to the document. document.AddHeaders(); // Get the default Header. Header header = document.Headers.odd; // Insert a Paragraph into the Header. Paragraph p0 = header.InsertParagraph(); // Appemd place holders for PageNumber and PageCount into the Header. // Word will replace these with the correct value for each Page. p0.Append("Page ("); p0.AppendPageNumber(PageNumberFormat.normal); p0.Append(" of "); p0.AppendPageCount(PageNumberFormat.normal); p0.Append(")"); // Save the document. document.Save(); } Insert a PageCount place holder into a Paragraph. This place holder should only be inserted into a Header or Footer Paragraph. Word will not automatically update this field if it is inserted into a document level Paragraph. The PageNumberFormat can be normal: (1, 2, ...) or Roman: (I, II, ...) The text index to insert this PageCount place holder at. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Add Headers to the document. document.AddHeaders(); // Get the default Header. Header header = document.Headers.odd; // Insert a Paragraph into the Header. Paragraph p0 = header.InsertParagraph("Page ( of )"); // Insert place holders for PageNumber and PageCount into the Header. // Word will replace these with the correct value for each Page. p0.InsertPageNumber(PageNumberFormat.normal, 6); p0.InsertPageCount(PageNumberFormat.normal, 11); // Save the document. document.Save(); } Append a PageCount place holder onto the end of a Paragraph. The PageNumberFormat can be normal: (1, 2, ...) or Roman: (I, II, ...) // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Add Headers to the document. document.AddHeaders(); // Get the default Header. Header header = document.Headers.odd; // Insert a Paragraph into the Header. Paragraph p0 = header.InsertParagraph(); // Appemd place holders for PageNumber and PageCount into the Header. // Word will replace these with the correct value for each Page. p0.Append("Page ("); p0.AppendPageNumber(PageNumberFormat.normal); p0.Append(" of "); p0.AppendPageCount(PageNumberFormat.normal); p0.Append(")"); // Save the document. document.Save(); } Set the Line spacing for this paragraph manually. The type of spacing to be set, can be either Before, After or Line (Standard line spacing). A float value of the amount of spacing. Equals the value that will be set in Word using the "Line and Paragraph spacing" button. Set the Line spacing for this paragraph using the Auto value. The type of spacing to be set automatically. Using Auto will set both Before and After. None will remove any line spacing. Paragraph that will be kept on the same page as the next paragraph. Paragraph with lines that will stay together on the same page. If the pPr element doesent exist it is created, either way it is returned by this function. The pPr element for this Paragraph. If the ind element doesent exist it is created, either way it is returned by this function. The ind element for this Paragraphs pPr. Create a new Picture. A unique id that identifies an Image embedded in this document. The name of this Picture. The description of this Picture. The width of this Picture. The height of this Picture. Creates an Edit either a ins or a del with the specified content and date The type of this edit (ins or del) The time stamp to use for this edit The initial content of this edit Gets the start index of this Text (text length before this text) Gets the end index of this Text (text length before this text + this texts length) The text value of this text element Gets the start index of this Text (text length before this text) Gets the end index of this Text (text length before this text + this texts length) The text value of this text element If a text element or delText element, starts or ends with a space, it must have the attribute space, otherwise it must not have it. The (t or delText) element check Represents a document. Top margin in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Bottom margin in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Left margin in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Right margin in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Header margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Footer margin value in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Page width in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Page height in points. 1pt = 1/72 of an inch. Word internally writes docx using units = 1/20th of a point. Returns true if any editing restrictions are imposed on this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { if(document.isProtected) Console.WriteLine("Protected"); else Console.WriteLine("Not protected"); // Save the document. document.Save(); } Returns a collection of Headers in this Document. A document typically contains three Headers. A default one (odd), one for the first page and one for even pages. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add header support to this document. document.AddHeaders(); // Get a collection of all headers in this document. Headers headers = document.Headers; // The header used for the first page of this document. Header first = headers.first; // The header used for odd pages of this document. Header odd = headers.odd; // The header used for even pages of this document. Header even = headers.even; } Returns a collection of Footers in this Document. A document typically contains three Footers. A default one (odd), one for the first page and one for even pages. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add footer support to this document. document.AddFooters(); // Get a collection of all footers in this document. Footers footers = document.Footers; // The footer used for the first page of this document. Footer first = footers.first; // The footer used for odd pages of this document. Footer odd = footers.odd; // The footer used for even pages of this document. Footer even = footers.even; } Should the Document use different Headers and Footers for odd and even pages? // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add header support to this document. document.AddHeaders(); // Get a collection of all headers in this document. Headers headers = document.Headers; // The header used for odd pages of this document. Header odd = headers.odd; // The header used for even pages of this document. Header even = headers.even; // Force the document to use a different header for odd and even pages. document.DifferentOddAndEvenPages = true; // Content can be added to the Headers in the same manor that it would be added to the main document. Paragraph p1 = odd.InsertParagraph(); p1.Append("This is the odd pages header."); Paragraph p2 = even.InsertParagraph(); p2.Append("This is the even pages header."); // Save all changes to this document. document.Save(); }// Release this document from memory. Should the Document use an independent Header and Footer for the first page? // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add header support to this document. document.AddHeaders(); // The header used for the first page of this document. Header first = document.Headers.first; // Force the document to use a different header for first page. document.DifferentFirstPage = true; // Content can be added to the Headers in the same manor that it would be added to the main document. Paragraph p = first.InsertParagraph(); p.Append("This is the first pages header."); // Save all changes to this document. document.Save(); }// Release this document from memory. Returns a list of Images in this document. Get the unique Id of every Image in this document. // Load a document. DocX document = DocX.Load(@"C:\Example\Test.docx"); // Loop through each Image in this document. foreach (Xceed.Words.NET.Image i in document.Images) { // Get the unique Id which identifies this Image. string uniqueId = i.Id; } Returns a list of custom properties in this document. Method 1: Get the name, type and value of each CustomProperty in this document. // Load Example.docx DocX document = DocX.Load(@"C:\Example\Test.docx"); /* * No two custom properties can have the same name, * so a Dictionary is the perfect data structure to store them in. * Each custom property can be accessed using its name. */ foreach (string name in document.CustomProperties.Keys) { // Grab a custom property using its name. CustomProperty cp = document.CustomProperties[name]; // Write this custom properties details to Console. Console.WriteLine(string.Format("Name: '{0}', Value: {1}", cp.Name, cp.Value)); } Console.WriteLine("Press any key..."); // Wait for the user to press a key before closing the Console. Console.ReadKey(); Method 2: Get the name, type and value of each CustomProperty in this document. // Load Example.docx DocX document = DocX.Load(@"C:\Example\Test.docx"); /* * No two custom properties can have the same name, * so a Dictionary is the perfect data structure to store them in. * The values of this Dictionary are CustomProperties. */ foreach (CustomProperty cp in document.CustomProperties.Values) { // Write this custom properties details to Console. Console.WriteLine(string.Format("Name: '{0}', Value: {1}", cp.Name, cp.Value)); } Console.WriteLine("Press any key..."); // Wait for the user to press a key before closing the Console. Console.ReadKey(); Returns the list of document core properties with corresponding values. Get the Text of this document. Write to Console the Text from this document. // Load a document DocX document = DocX.Load(@"C:\Example\Test.docx"); // Get the text of this document. string text = document.Text; // Write the text of this document to Console. Console.Write(text); // Wait for the user to press a key before closing the console window. Console.ReadKey(); Get the Footnotes of this document Get the Endnotes of this document Returns the type of editing protection imposed on this document. The type of editing protection imposed on this document. Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Make sure the document is protected before checking the protection type. if (document.isProtected) { EditRestrictions protection = document.GetProtectionType(); Console.WriteLine("Document is protected using " + protection.ToString()); } else Console.WriteLine("Document is not protected."); // Save the document. document.Save(); } Add editing protection to this document. The type of protection to add to this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Allow no editing, only the adding of comment. document.AddProtection(EditRestrictions.comments); // Save the document. document.Save(); } Remove editing protection from this document. // Create a new document. using (DocX document = DocX.Create(@"Test.docx")) { // Remove any editing restrictions that are imposed on this document. document.RemoveProtection(); // Save the document. document.Save(); } Insert the contents of another document at the end of this document. The document to insert at the end of this document. When true, document is added at the end. If False, document is added at the beginning. Create a new document and insert an old document into it. // Create a new document. using (DocX newDocument = DocX.Create(@"NewDocument.docx")) { // Load an old document. using (DocX oldDocument = DocX.Load(@"OldDocument.docx")) { // Insert the old document into the new document. newDocument.InsertDocument(oldDocument); // Save the new document. newDocument.Save(); }// Release the old document from memory. }// Release the new document from memory. If the document being inserted contains Images, CustomProperties and or custom styles, these will be correctly inserted into the new document. In the case of Images, new ID's are generated for the Images being inserted to avoid ID conflicts. CustomProperties with the same name will be ignored not replaced. Insert a new Table at the end of this document. The number of columns to create. The number of rows to create. A new Table. Insert a new Table with 2 columns and 3 rows, at the end of a document. // Create a document. using (DocX document = DocX.Create(@"C:\Example\Test.docx")) { // Create a new Table with 2 columns and 3 rows. Table newTable = document.InsertTable(2, 3); // Set the design of this Table. newTable.Design = TableDesign.LightShadingAccent2; // Set the column names. newTable.Rows[0].Cells[0].Paragraph.InsertText("Ice Cream", false); newTable.Rows[0].Cells[1].Paragraph.InsertText("Price", false); // Fill row 1 newTable.Rows[1].Cells[0].Paragraph.InsertText("Chocolate", false); newTable.Rows[1].Cells[1].Paragraph.InsertText("€3:50", false); // Fill row 2 newTable.Rows[2].Cells[0].Paragraph.InsertText("Vanilla", false); newTable.Rows[2].Cells[1].Paragraph.InsertText("€3:00", false); // Save all changes made to document b. document.Save(); }// Release this document from memory. Insert a Table into this document. The Table's source can be a completely different document. The Table to insert. The index to insert this Table at. The Table now associated with this document. Extract a Table from document a and insert it into document b, at index 10. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"C:\Example\a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"C:\Example\b.docx")) { /* * Insert the Table that was extracted from document a, into document b. * This creates a new Table that is now associated with document b. */ Table newTable = documentB.InsertTable(10, t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a Table into this document. The Table's source can be a completely different document. The Table to insert. The Table now associated with this document. Extract a Table from document a and insert it at the end of document b. // Place holder for a Table. Table t; // Load document a. using (DocX documentA = DocX.Load(@"C:\Example\a.docx")) { // Get the first Table from this document. t = documentA.Tables[0]; } // Load document b. using (DocX documentB = DocX.Load(@"C:\Example\b.docx")) { /* * Insert the Table that was extracted from document a, into document b. * This creates a new Table that is now associated with document b. */ Table newTable = documentB.InsertTable(t); // Save all changes made to document b. documentB.Save(); }// Release this document from memory. Insert a new Table at the end of this document. The number of columns to create. The number of rows to create. The index to insert this Table at. A new Table. Insert a new Table with 2 columns and 3 rows, at index 37 in this document. // Create a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Create a new Table with 3 rows and 2 columns. Insert this Table at index 37. Table newTable = document.InsertTable(37, 3, 2); // Set the design of this Table. newTable.Design = TableDesign.LightShadingAccent3; // Set the column names. newTable.Rows[0].Cells[0].Paragraph.InsertText("Ice Cream", false); newTable.Rows[0].Cells[1].Paragraph.InsertText("Price", false); // Fill row 1 newTable.Rows[1].Cells[0].Paragraph.InsertText("Chocolate", false); newTable.Rows[1].Cells[1].Paragraph.InsertText("€3:50", false); // Fill row 2 newTable.Rows[2].Cells[0].Paragraph.InsertText("Vanilla", false); newTable.Rows[2].Cells[1].Paragraph.InsertText("€3:00", false); // Save all changes made to document b. document.Save(); }// Release this document from memory. Creates a document using a Stream. The Stream to create the document from. Returns a DocX object which represents the document. Creating a document from a FileStream. // Use a FileStream fs to create a new document. using(FileStream fs = new FileStream(@"C:\Example\Test.docx", FileMode.Create)) { // Load the document using fs using (DocX document = DocX.Create(fs)) { // Do something with the document here. // Save all changes made to this document. document.Save(); }// Release this document from memory. } Creating a document in a SharePoint site. using(SPSite mySite = new SPSite("http://server/sites/site")) { // Open a connection to the SharePoint site using(SPWeb myWeb = mySite.OpenWeb()) { // Create a MemoryStream ms. using (MemoryStream ms = new MemoryStream()) { // Create a document using ms. using (DocX document = DocX.Create(ms)) { // Do something with the document here. // Save all changes made to this document. document.Save(); }// Release this document from memory // Add the document to the SharePoint site web.Files.Add("filename", ms.ToArray(), true); } } } Creates a document using a fully qualified or relative filename. The fully qualified or relative filename. Returns a DocX object which represents the document. // Create a document using a relative filename. using (DocX document = DocX.Create(@"..\Test.docx")) { // Do something with the document here. // Save all changes made to this document. document.Save(); }// Release this document from memory // Create a document using a relative filename. using (DocX document = DocX.Create(@"..\Test.docx")) { // Do something with the document here. // Save all changes made to this document. document.Save(); }// Release this document from memory Loads a document into a DocX object using a Stream. The Stream to load the document from. Returns a DocX object which represents the document. Loading a document from a FileStream. // Open a FileStream fs to a document. using (FileStream fs = new FileStream(@"C:\Example\Test.docx", FileMode.Open)) { // Load the document using fs. using (DocX document = DocX.Load(fs)) { // Do something with the document here. // Save all changes made to the document. document.Save(); }// Release this document from memory. } Loading a document from a SharePoint site. // Get the SharePoint site that you want to access. using (SPSite mySite = new SPSite("http://server/sites/site")) { // Open a connection to the SharePoint site using (SPWeb myWeb = mySite.OpenWeb()) { // Grab a document stored on this site. SPFile file = web.GetFile("Source_Folder_Name/Source_File"); // DocX.Load requires a Stream, so open a Stream to this document. Stream str = new MemoryStream(file.OpenBinary()); // Load the file using the Stream str. using (DocX document = DocX.Load(str)) { // Do something with the document here. // Save all changes made to the document. document.Save(); }// Release this document from memory. } } Loads a document into a DocX object using a fully qualified or relative filename. The fully qualified or relative filename. Returns a DocX object which represents the document. // Load a document using its fully qualified filename using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Do something with the document here // Save all changes made to document. document.Save(); }// Release this document from memory. // Load a document using its relative filename. using(DocX document = DocX.Load(@"..\..\Test.docx")) { // Do something with the document here. // Save all changes made to document. document.Save(); }// Release this document from memory. Applies document template to the document. Document template may include styles, headers, footers, properties, etc. as well as text content. The path to the document template file. The document template file not found. Applies document template to the document. Document template may include styles, headers, footers, properties, etc. as well as text content. The path to the document template file. Whether to copy the document template text content to document. The document template file not found. Applies document template to the document. Document template may include styles, headers, footers, properties, etc. as well as text content. The stream of the document template file. Applies document template to the document. Document template may include styles, headers, footers, properties, etc. as well as text content. The stream of the document template file. Whether to copy the document template text content to document. Add an Image into this document from a fully qualified or relative filename. The fully qualified or relative filename. An Image file. Add an Image into this document from a fully qualified filename. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Add an Image from a file. document.AddImage(@"C:\Example\Image.png"); // Save all changes made to this document. document.Save(); }// Release this document from memory. Add an Image into this document from a Stream. A Stream stream. MIME type of image. An Image file. Add an Image into a document using a Stream. // Open a FileStream fs to an Image. using (FileStream fs = new FileStream(@"C:\Example\Image.jpg", FileMode.Open)) { // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Add an Image from a filestream fs. document.AddImage(fs); // Save all changes made to this document. document.Save(); }// Release this document from memory. } Adds a hyperlink with a uri to a document and creates a Paragraph which uses it. The text as displayed by the hyperlink. The hyperlink itself. Returns a hyperlink with a uri that can be inserted into a Paragraph. Adds a hyperlink to a document and creates a Paragraph which uses it. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add a hyperlink to this document. Hyperlink h = document.AddHyperlink("Google", new Uri("http://www.google.com")); // Add a new Paragraph to this document. Paragraph p = document.InsertParagraph(); p.Append("My favourite search engine is "); p.AppendHyperlink(h); p.Append(", I think it's great."); // Save all changes made to this document. document.Save(); } Adds a hyperlink with an anchor to a document and creates a Paragraph which uses it. The text as displayed by the hyperlink. The anchor to a bookmark. Returns a hyperlink with an anchor that can be inserted into a Paragraph. Adds three new Headers to this document. One for the first page, one for odd pages and one for even pages. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add header support to this document. document.AddHeaders(); // Get a collection of all headers in this document. Headers headers = document.Headers; // The header used for the first page of this document. Header first = headers.first; // The header used for odd pages of this document. Header odd = headers.odd; // The header used for even pages of this document. Header even = headers.even; // Force the document to use a different header for first, odd and even pages. document.DifferentFirstPage = true; document.DifferentOddAndEvenPages = true; // Content can be added to the Headers in the same manor that it would be added to the main document. Paragraph p = first.InsertParagraph(); p.Append("This is the first pages header."); // Save all changes to this document. document.Save(); }// Release this document from memory. Adds three new Footers to this document. One for the first page, one for odd pages and one for even pages. // Create a document. using (DocX document = DocX.Create(@"Test.docx")) { // Add footer support to this document. document.AddFooters(); // Get a collection of all footers in this document. Footers footers = document.Footers; // The footer used for the first page of this document. Footer first = footers.first; // The footer used for odd pages of this document. Footer odd = footers.odd; // The footer used for even pages of this document. Footer even = footers.even; // Force the document to use a different footer for first, odd and even pages. document.DifferentFirstPage = true; document.DifferentOddAndEvenPages = true; // Content can be added to the Footers in the same manor that it would be added to the main document. Paragraph p = first.InsertParagraph(); p.Append("This is the first pages footer."); // Save all changes to this document. document.Save(); }// Release this document from memory. Save this document back to the location it was loaded from. // Load a document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // Add an Image from a file. document.AddImage(@"C:\Example\Image.jpg"); // Save all changes made to this document. document.Save(); }// Release this document from memory. Save this document to a file. The filename to save this document as. Load a document from one file and save it to another. // Load a document using its fully qualified filename. DocX document = DocX.Load(@"C:\Example\Test1.docx"); // Insert a new Paragraph document.InsertParagraph("Hello world!", false); // Save the document to a new location. document.SaveAs(@"C:\Example\Test2.docx"); Load a document from a Stream and save it to a file. DocX document; using (FileStream fs1 = new FileStream(@"C:\Example\Test1.docx", FileMode.Open)) { // Load a document using a stream. document = DocX.Load(fs1); // Insert a new Paragraph document.InsertParagraph("Hello world again!", false); } // Save the document to a new location. document.SaveAs(@"C:\Example\Test2.docx"); Save this document to a Stream. The Stream to save this document to. Load a document from a file and save it to a Stream. // Place holder for a document. DocX document; using (FileStream fs1 = new FileStream(@"C:\Example\Test1.docx", FileMode.Open)) { // Load a document using a stream. document = DocX.Load(fs1); // Insert a new Paragraph document.InsertParagraph("Hello world again!", false); } using (FileStream fs2 = new FileStream(@"C:\Example\Test2.docx", FileMode.Create)) { // Save the document to a different stream. document.SaveAs(fs2); } // Release this document from memory. document.Dispose(); Load a document from one Stream and save it to another. DocX document; using (FileStream fs1 = new FileStream(@"C:\Example\Test1.docx", FileMode.Open)) { // Load a document using a stream. document = DocX.Load(fs1); // Insert a new Paragraph document.InsertParagraph("Hello world again!", false); } using (FileStream fs2 = new FileStream(@"C:\Example\Test2.docx", FileMode.Create)) { // Save the document to a different stream. document.SaveAs(fs2); } Add a core property to this document. If a core property already exists with the same name it will be replaced. Core property names are case insensitive. The property name. The property value. Add a core properties of each type to a document. // Load Example.docx using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // If this document does not contain a core property called 'forename', create one. if (!document.CoreProperties.ContainsKey("forename")) { // Create a new core property called 'forename' and set its value. document.AddCoreProperty("forename", "Cathal"); } // Get this documents core property called 'forename'. string forenameValue = document.CoreProperties["forename"]; // Print all of the information about this core property to Console. Console.WriteLine(string.Format("Name: '{0}', Value: '{1}'\nPress any key...", "forename", forenameValue)); // Save all changes made to this document. document.Save(); } // Release this document from memory. // Wait for the user to press a key before exiting. Console.ReadKey(); Add a custom property to this document. If a custom property already exists with the same name it will be replace. CustomProperty names are case insensitive. The CustomProperty to add to this document. Add a custom properties of each type to a document. // Load Example.docx using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // A CustomProperty called forename which stores a string. CustomProperty forename; // If this document does not contain a custom property called 'forename', create one. if (!document.CustomProperties.ContainsKey("forename")) { // Create a new custom property called 'forename' and set its value. document.AddCustomProperty(new CustomProperty("forename", "Cathal")); } // Get this documents custom property called 'forename'. forename = document.CustomProperties["forename"]; // Print all of the information about this CustomProperty to Console. Console.WriteLine(string.Format("Name: '{0}', Value: '{1}'\nPress any key...", forename.Name, forename.Value)); // Save all changes made to this document. document.Save(); } // Release this document from memory. // Wait for the user to press a key before exiting. Console.ReadKey(); Create an equation and insert it in the new paragraph Insert a chart in document Insert a chart in document after the specified paragraph Create a new List Add a list item to an existing list Insert a list in the document The list to insert into the document. The list that was inserted into the document. Insert a list at an index location in the document Index in document to insert the list. The list that was inserted into the document. Insert a default Table of Contents in the current document Insert a Table of Contents in the current document Insert a Table of Contents in the current document at a specific location (prior to the referenced paragraph) Copy the Document into a new Document Returns a copy of a the Document Adds a Header to a document. If the document already contains a Header it will be replaced. The Header that was added to the document. Update the custom properties inside the document The DocX document The property used inside the document The new value for the property Different version of Word create different Document XML. Finds the next free Id for bookmarkStart/docPr. Releases all resources used by this document. If you take advantage of the using keyword, Dispose() is automatically called for you. // Load document. using (DocX document = DocX.Load(@"C:\Example\Test.docx")) { // The document is only in memory while in this scope. }// Dispose() is automatically called at this point. This example is equilivant to the one above example. // Load document. DocX document = DocX.Load(@"C:\Example\Test.docx"); // Do something with the document here. // Dispose of the document. document.Dispose(); Sets margin for all the pages in a DocX document in inches. Margin from the top. -1 for no change. Margin from the bottom. -1 for no change. Margin from the right. -1 for no change. Margin from the left. -1 for no change.