API Reference
WordList
Represents a collection of paragraphs formatted as a list and exposes methods to manipulate the list's numbering and style.
Inheritance
- WordElement
- WordList
Constructors
public WordList(WordDocument wordDocument, WordHeaderFooter headerFooter) #Initializes a new instance of the WordList class.
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- The Word document.
- isToc System.Boolean = false
- Indicates if the list should be treated as a TOC.
public WordList(WordDocument wordDocument, WordParagraph paragraph, Boolean isToc = false) #Initializes a new instance of the WordList class with a starting paragraph.
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- The Word document.
- paragraph OfficeIMO.Word.WordParagraph
- The starting paragraph.
- isToc System.Boolean = false
- Indicates if the list should be treated as a TOC.
Methods
public static WordList AddCustomBulletList(WordDocument document, Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #WordListCreates a bulleted list using a custom symbol and formatting.
Parameters
- document OfficeIMO.Word.WordDocument
- The parent document.
- symbol System.Char
- The character to use as the bullet symbol.
- fontName System.String
- Font name used for the bullet symbol.
- colorHex System.String
- Optional hexadecimal color for the symbol.
- fontSize System.Nullable{System.Int32} = null
- Optional font size for the symbol in points.
Returns
The created WordList.
public static WordList AddCustomBulletList(WordDocument document, WordListLevelKind kind, String fontName, Nullable<Color> color = null, String colorHex = null, Nullable<Int32> fontSize = null) #WordListCreates a custom bulleted list using a predefined WordBulletSymbol.
Parameters
- document OfficeIMO.Word.WordDocument
- The parent document.
- symbol OfficeIMO.Word.WordBulletSymbol
- Predefined bullet symbol to use.
- fontName System.String
- Font name used for the symbol.
- color System.Nullable{SixLabors.ImageSharp.Color} = null
- Optional Color for the symbol.
- colorHex System.String = null
- Optional color specified as hex string. Ignored when color is provided.
- fontSize System.Nullable{System.Int32} = null
- Optional font size in points.
Returns
The created WordList.
AddCustomBulletList(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordListLevelKind kind, System.String fontName, System.Nullable{SixLabors.ImageSharp.Color} color, System.String colorHex, System.Nullable{System.Int32} fontSize) #Creates a bulleted list using one of the predefined WordListLevelKind values.
Parameters
- document OfficeIMO.Word.WordDocument
- The parent document.
- kind OfficeIMO.Word.WordListLevelKind
- Determines which bullet symbol to use.
- fontName System.String
- Font name used for the symbol.
- color System.Nullable{SixLabors.ImageSharp.Color}
- Optional symbol color.
- colorHex System.String
- Optional color specified as hex string. Ignored when color is provided.
- fontSize System.Nullable{System.Int32}
- Optional font size in points.
Returns
The created WordList.
public static WordList AddCustomList(WordDocument document) #WordListCreates a list that does not contain any predefined levels. Levels can be configured manually after creation.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent document where the list will be added.
Returns
The created WordList.
public WordParagraph AddItem(WordParagraph wordParagraph, Int32 level = 0) #WordParagraphAdds a new empty item to the list.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph
- The paragraph after which the item should be inserted. If null the item is appended at the default position.
- level System.Int32 = 0
- The zero-based list level for the new item.
Returns
The newly created WordParagraph representing the list item.
public WordParagraph AddItem(String text, Int32 level = 0, WordParagraph wordParagraph = null) #WordParagraphAdds a new item to the list and optionally sets its text.
Parameters
- text System.String
- Text to assign to the new list item. Pass null to insert an empty item.
- level System.Int32 = 0
- The zero-based list level for the item.
- wordParagraph OfficeIMO.Word.WordParagraph = null
- The paragraph after which the item is inserted. When null the item is appended in the default position.
Returns
The WordParagraph representing the created list item.
AddList(OfficeIMO.Word.WordListStyle style) #Adds a list to the document with the specified style.
Parameters
- style OfficeIMO.Word.WordListStyle
- The list style to apply.
public WordList AddListLevel(Int32 levelIndex, Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #WordListAdds a new bullet list level using a custom symbol character.
Parameters
- levelIndex System.Int32
- Index of the level starting from 1.
- symbol System.Char
- Character used for the bullet.
- fontName System.String
- Font name used for the symbol.
- colorHex System.String
- Bullet color specified as hex string.
- fontSize System.Nullable{System.Int32} = null
- Optional font size in points.
Returns
The current WordList.
public WordList AddListLevel(Int32 levelIndex, WordListLevelKind kind, String fontName, Nullable<Color> color = null, String colorHex = null, Nullable<Int32> fontSize = null) #WordListAdds a new bullet list level using a predefined WordBulletSymbol.
Parameters
- levelIndex System.Int32
- Index of the level starting from 1.
- symbol OfficeIMO.Word.WordBulletSymbol
- Predefined bullet symbol.
- fontName System.String
- Font name used for the symbol.
- color System.Nullable{SixLabors.ImageSharp.Color} = null
- Optional symbol color.
- colorHex System.String = null
- Optional color specified as hex string. Ignored when color is provided.
- fontSize System.Nullable{System.Int32} = null
- Optional font size in points.
Returns
The current WordList.
AddListLevel(System.Int32 levelIndex, OfficeIMO.Word.WordListLevelKind kind, System.String fontName, System.Nullable{SixLabors.ImageSharp.Color} color, System.String colorHex, System.Nullable{System.Int32} fontSize) #Adds a new bullet list level using one of the predefined WordListLevelKind values.
Parameters
- levelIndex System.Int32
- Index of the level starting from 1.
- kind OfficeIMO.Word.WordListLevelKind
- Determines which bullet symbol to use.
- fontName System.String
- Font name used for the symbol.
- color System.Nullable{SixLabors.ImageSharp.Color}
- Optional symbol color.
- colorHex System.String
- Optional color specified as hex string. Ignored when color is provided.
- fontSize System.Nullable{System.Int32}
- Optional font size in points.
Returns
The current WordList.
public static WordList AddPictureBulletList(WordDocument document, Stream imageStream, String fileName) #WordListCreates a custom bullet list using an image as the bullet symbol.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent document where the list will be added.
- imageStream System.IO.Stream
- Stream containing the image data.
- fileName System.String
- File name used to determine the image type.
Returns
The created WordList.
public static WordList AddPictureBulletList(WordDocument document, String imagePath) #WordListCreates a custom bullet list using an image file as the bullet symbol.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent document where the list will be added.
- imagePath System.String
- Path to the image file.
Returns
The created WordList.
public WordList Clone() #WordListCreates a copy of this list after the last item.
Returns
The newly created WordList.
Exceptions
InvalidOperationException– Thrown when the list contains no items.
public WordList Clone(WordParagraph paragraph, Boolean after = true) #WordListClones this list and inserts it relative to the provided paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- The reference paragraph used for insertion.
- after System.Boolean = true
- If set to true the clone is inserted after the reference paragraph; otherwise it is inserted before.
Returns
The cloned WordList.
public Void ConvertToBulleted() #VoidConverts this list to a bulleted style while preserving existing list items.
public Void ConvertToNumbered() #VoidConverts this list to a numbered style while preserving existing list items.
CreateNumberingDefinition(OfficeIMO.Word.WordDocument document) #Creates the numbering definitions part if it doesn't exist.
Parameters
- document OfficeIMO.Word.WordDocument
- The Word document.
DefaultNumberingInstance(DocumentFormat.OpenXml.Wordprocessing.AbstractNumId abstractNumId, System.Int32 numberId) #Creates a default numbering instance.
Parameters
- abstractNumId DocumentFormat.OpenXml.Wordprocessing.AbstractNumId
- The abstract numbering ID.
- numberId System.Int32
- The numbering instance ID.
GetAbstractNum() #Retrieves the AbstractNum associated with this list.
GetInsertionReference(OfficeIMO.Word.WordParagraph wordParagraph) #Determines the insertion reference for a new item. When an anchor paragraph is supplied, it is used only for the first insertion; subsequent items are chained after the last list item to preserve order.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph
- Anchor paragraph requested for the insertion.
Returns
The OpenXmlElement that should be used as the insertion point, if any.
GetNextAbstractNum(DocumentFormat.OpenXml.Wordprocessing.Numbering numbering) #Gets the next available abstract numbering ID.
Parameters
- numbering DocumentFormat.OpenXml.Wordprocessing.Numbering
- The numbering definitions.
GetNextNumberingInstance(DocumentFormat.OpenXml.Wordprocessing.Numbering numbering) #Gets the next available numbering instance ID.
Parameters
- numbering DocumentFormat.OpenXml.Wordprocessing.Numbering
- The numbering definitions.
GetNumberingProperty``1(System.Func{DocumentFormat.OpenXml.Wordprocessing.NumberingSymbolRunProperties,``0} propertySelector, ``0 defaultValue) #Gets a numbering property using a selector function.
Type Parameters
- T
- The type of the property.
Parameters
- propertySelector System.Func{DocumentFormat.OpenXml.Wordprocessing.NumberingSymbolRunProperties,``0}
- The selector function to extract the property.
- defaultValue ``0
- The default value if the property is not found.
public Void Merge(WordList documentList) #VoidMerges another list into this list.
Parameters
- documentList OfficeIMO.Word.WordList
- The list whose items should be moved into this instance.
ReplaceAbstractNum(DocumentFormat.OpenXml.Wordprocessing.AbstractNum newAbstract) #Replaces the underlying abstract numbering definition while keeping the current numbering instance.
Parameters
- newAbstract DocumentFormat.OpenXml.Wordprocessing.AbstractNum
- The new abstract numbering definition.
RestartNumberingInstance(DocumentFormat.OpenXml.Wordprocessing.AbstractNumId abstractNumId, System.Int32 numberId) #Creates a numbering instance that restarts numbering after a break.
Parameters
- abstractNumId DocumentFormat.OpenXml.Wordprocessing.AbstractNumId
- The abstract numbering ID.
- numberId System.Int32
- The numbering instance ID.
SetNumberingProperty(System.Action{DocumentFormat.OpenXml.Wordprocessing.NumberingSymbolRunProperties} setProperty, System.Boolean applyWhenNull) #Sets a numbering property using the specified action.
Parameters
- setProperty System.Action{DocumentFormat.OpenXml.Wordprocessing.NumberingSymbolRunProperties}
- The action to set the property.
- applyWhenNull System.Boolean
- Indicates whether to apply the property when it is null.
public Void SetStartNumberingValue(Int32 value, Int32 level = 0) #VoidSets the starting number for the specified list level. Updates both the abstract definition and the list instance override.
Parameters
- value System.Int32
- Starting number for the level.
- level System.Int32 = 0
- Zero-based list level.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public Boolean IsToc { get; } #Indicates whether the list is treated as a Table of Contents (TOC).
public List<WordParagraph> ListItems { get; } #Gets all the list items associated with this WordList.
public Boolean RestartNumberingAfterBreak { get; set; } #Restarts numbering of a list after a break. Requires a list to be set to RestartNumbering overall.
public WordListNumbering Numbering { get; } #Exposes the numbering properties of the list, allowing for customization.
public Boolean Bold { get; set; } #Gets or sets a value indicating whether the numbering symbols are bold.
public Nullable<Int32> FontSize { get; set; } #Gets or sets the font size of the numbering symbols in points.
public Nullable<Color> Color { get; set; } #Gets or sets the color of the numbering symbols.
public String ColorHex { get; set; } #Gets or sets the hexadecimal color value of the numbering symbols.
public Boolean Italic { get; set; } #Gets or sets a value indicating whether the numbering symbols are italicized.
public Nullable<UnderlineValues> Underline { get; set; } #Gets or sets the underline style of the numbering symbols.
public Boolean Strike { get; set; } #Gets or sets a value indicating whether the numbering symbols have a strikethrough.
public Boolean DoubleStrike { get; set; } #Gets or sets a value indicating whether the numbering symbols have a double strikethrough.
public String FontName { get; set; } #Gets or sets the font name of the numbering symbols.
public WordListStyle Style { get; } #Gets the list style or Custom when the list does not match a built-in style.
Fields
_isToc #This provides a way to set items to be treated with heading style