OfficeIMO

API Reference

Class

WordList

Namespace OfficeIMO.Word
Assembly OfficeIMO.Word

Represents a collection of paragraphs formatted as a list and exposes methods to manipulate the list's numbering and style.

Inheritance

Constructors

WordList 4 overloads
public WordList(WordDocument wordDocument, WordHeaderFooter headerFooter) #

Initializes a new instance of the WordList class.

Parameters

wordDocument OfficeIMO.Word.WordDocument requiredposition: 0
The Word document.
isToc System.Boolean = false requiredposition: 1
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 requiredposition: 0
The Word document.
paragraph OfficeIMO.Word.WordParagraph requiredposition: 1
The starting paragraph.
isToc System.Boolean = false optionalposition: 2
Indicates if the list should be treated as a TOC.
WordList(OfficeIMO.Word.WordDocument wordDocument, System.Int32 numberId) #

Initializes a new instance of the WordList class with a specific number ID.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
numberId System.Int32 required
The numbering ID.
WordList(OfficeIMO.Word.WordDocument wordDocument, OfficeIMO.Word.WordHeaderFooter headerFooter) #

Initializes a new instance of the WordList class for headers and footers.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
The Word document.
headerFooter OfficeIMO.Word.WordHeaderFooter required
The header or footer.

Methods

AddCustomBulletList 3 overloads
public static WordList AddCustomBulletList(WordDocument document, Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #
Returns: WordList

Creates a bulleted list using a custom symbol and formatting.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
The parent document.
symbol System.Char requiredposition: 1
The character to use as the bullet symbol.
fontName System.String requiredposition: 2
Font name used for the bullet symbol.
colorHex System.String requiredposition: 3
Optional hexadecimal color for the symbol.
fontSize System.Nullable{System.Int32} = null optionalposition: 4
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) #
Returns: WordList

Creates a custom bulleted list using a predefined WordBulletSymbol.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
The parent document.
symbol OfficeIMO.Word.WordBulletSymbol requiredposition: 1
Predefined bullet symbol to use.
fontName System.String requiredposition: 2
Font name used for the symbol.
color System.Nullable{SixLabors.ImageSharp.Color} = null optionalposition: 3
Optional Color for the symbol.
colorHex System.String = null optionalposition: 4
Optional color specified as hex string. Ignored when color is provided.
fontSize System.Nullable{System.Int32} = null optionalposition: 5
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 required
The parent document.
kind OfficeIMO.Word.WordListLevelKind required
Determines which bullet symbol to use.
fontName System.String required
Font name used for the symbol.
color System.Nullable{SixLabors.ImageSharp.Color} required
Optional symbol color.
colorHex System.String required
Optional color specified as hex string. Ignored when color is provided.
fontSize System.Nullable{System.Int32} required
Optional font size in points.

Returns

The created WordList.

public static WordList AddCustomList(WordDocument document) #
Returns: WordList

Creates a list that does not contain any predefined levels. Levels can be configured manually after creation.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
Parent document where the list will be added.

Returns

The created WordList.

AddItem 2 overloads
public WordParagraph AddItem(WordParagraph wordParagraph, Int32 level = 0) #
Returns: WordParagraph

Adds a new empty item to the list.

Parameters

wordParagraph OfficeIMO.Word.WordParagraph requiredposition: 0
The paragraph after which the item should be inserted. If null the item is appended at the default position.
level System.Int32 = 0 optionalposition: 1
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) #
Returns: WordParagraph

Adds a new item to the list and optionally sets its text.

Parameters

text System.String requiredposition: 0
Text to assign to the new list item. Pass null to insert an empty item.
level System.Int32 = 0 optionalposition: 1
The zero-based list level for the item.
wordParagraph OfficeIMO.Word.WordParagraph = null optionalposition: 2
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 required
The list style to apply.
AddListLevel 3 overloads
public WordList AddListLevel(Int32 levelIndex, Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #
Returns: WordList

Adds a new bullet list level using a custom symbol character.

Parameters

levelIndex System.Int32 requiredposition: 0
Index of the level starting from 1.
symbol System.Char requiredposition: 1
Character used for the bullet.
fontName System.String requiredposition: 2
Font name used for the symbol.
colorHex System.String requiredposition: 3
Bullet color specified as hex string.
fontSize System.Nullable{System.Int32} = null optionalposition: 4
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) #
Returns: WordList

Adds a new bullet list level using a predefined WordBulletSymbol.

Parameters

levelIndex System.Int32 requiredposition: 0
Index of the level starting from 1.
symbol OfficeIMO.Word.WordBulletSymbol requiredposition: 1
Predefined bullet symbol.
fontName System.String requiredposition: 2
Font name used for the symbol.
color System.Nullable{SixLabors.ImageSharp.Color} = null optionalposition: 3
Optional symbol color.
colorHex System.String = null optionalposition: 4
Optional color specified as hex string. Ignored when color is provided.
fontSize System.Nullable{System.Int32} = null optionalposition: 5
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 required
Index of the level starting from 1.
kind OfficeIMO.Word.WordListLevelKind required
Determines which bullet symbol to use.
fontName System.String required
Font name used for the symbol.
color System.Nullable{SixLabors.ImageSharp.Color} required
Optional symbol color.
colorHex System.String required
Optional color specified as hex string. Ignored when color is provided.
fontSize System.Nullable{System.Int32} required
Optional font size in points.

Returns

The current WordList.

AddPictureBulletList 2 overloads
public static WordList AddPictureBulletList(WordDocument document, Stream imageStream, String fileName) #
Returns: WordList

Creates a custom bullet list using an image as the bullet symbol.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
Parent document where the list will be added.
imageStream System.IO.Stream requiredposition: 1
Stream containing the image data.
fileName System.String requiredposition: 2
File name used to determine the image type.

Returns

The created WordList.

public static WordList AddPictureBulletList(WordDocument document, String imagePath) #
Returns: WordList

Creates a custom bullet list using an image file as the bullet symbol.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
Parent document where the list will be added.
imagePath System.String requiredposition: 1
Path to the image file.

Returns

The created WordList.

Clone 2 overloads
public WordList Clone() #
Returns: WordList

Creates 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) #
Returns: WordList

Clones this list and inserts it relative to the provided paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph requiredposition: 0
The reference paragraph used for insertion.
after System.Boolean = true optionalposition: 1
If set to true the clone is inserted after the reference paragraph; otherwise it is inserted before.

Returns

The cloned WordList.

public Void ConvertToBulleted() #
Returns: Void

Converts this list to a bulleted style while preserving existing list items.

public Void ConvertToNumbered() #
Returns: Void

Converts 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 required
The Word document.
DefaultNumberingInstance(DocumentFormat.OpenXml.Wordprocessing.AbstractNumId abstractNumId, System.Int32 numberId) #

Creates a default numbering instance.

Parameters

abstractNumId DocumentFormat.OpenXml.Wordprocessing.AbstractNumId required
The abstract numbering ID.
numberId System.Int32 required
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 required
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 required
The numbering definitions.
GetNextNumberingInstance(DocumentFormat.OpenXml.Wordprocessing.Numbering numbering) #

Gets the next available numbering instance ID.

Parameters

numbering DocumentFormat.OpenXml.Wordprocessing.Numbering required
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} required
The selector function to extract the property.
defaultValue ``0 required
The default value if the property is not found.
public Void Merge(WordList documentList) #
Returns: Void

Merges another list into this list.

Parameters

documentList OfficeIMO.Word.WordList requiredposition: 0
The list whose items should be moved into this instance.
public Void Remove() #
Returns: Void

Removes the list from the document including all list items.

ReplaceAbstractNum(DocumentFormat.OpenXml.Wordprocessing.AbstractNum newAbstract) #

Replaces the underlying abstract numbering definition while keeping the current numbering instance.

Parameters

newAbstract DocumentFormat.OpenXml.Wordprocessing.AbstractNum required
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 required
The abstract numbering ID.
numberId System.Int32 required
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} required
The action to set the property.
applyWhenNull System.Boolean required
Indicates whether to apply the property when it is null.
public Void SetStartNumberingValue(Int32 value, Int32 level = 0) #
Returns: Void

Sets the starting number for the specified list level. Updates both the abstract definition and the list instance override.

Parameters

value System.Int32 requiredposition: 0
Starting number for the level.
level System.Int32 = 0 optionalposition: 1
Zero-based list level.

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