WordStyle
OfficeIMO.Word
A style defined in a WordDocument. Reading and setting its properties works directly on the document's style definition, so every paragraph, run or table that uses the style follows the change.
Inheritance
- object
- WordStyle
Remarks
Formatting properties return the value declared by this style, not the effective value inherited from its base style or the document defaults. A null value inherits; assigning null removes the declaration.
Usage
Explore 13 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 10
- Method WordDocument.EmbedFont
- Method WordStyle.SetList
- Method WordStyle.SetTableBorders
- Method WordStyleCollection.AddCharacterStyle
- Method WordStyleCollection.AddParagraphStyle
- Method WordStyleCollection.AddTableStyle
- Method WordStyleCollection.Get
- Method WordStyleCollection.GetEnumerator
- Method WordStyleCollection.GetOrAdd
- Property WordStyleCollection.Item
Accepted by parameters 3
- Method WordParagraph.SetCharacterStyle
- Method WordParagraph.SetStyle
- Method WordTable.SetStyle
Methods
public WordTableStyleRegionFormat GetTableRegion(WordTableStyleRegion region) #Gets the formatting this table style applies to one region of a table.
Parameters
- region OfficeIMO.Word.WordTableStyleRegion
- The table region.
Returns
WordTableStyleRegionFormatExceptions
InvalidOperationException– The style is not a table style.
public WordStyle SetList(WordList? list, int level = 0) #Numbers paragraphs that use this style with a level of a list, or removes the numbering.
Parameters
- list OfficeIMO.Word.WordList?
- The list to number with, or null to remove numbering.
- level int = 0
- The zero-based list level.
public WordStyle SetTableBorders(WordBorderStyle style, OfficeLength size, OfficeColor color) #Sets the outside and inside borders that this table style draws around and between cells.
Parameters
- style OfficeIMO.Word.WordBorderStyle
- The border line style; WordBorderStyle.None removes the borders.
- size OfficeIMO.OfficeLength
- The border width, rounded to an eighth of a point.
- color OfficeIMO.OfficeColor
- The border colour.
public override string ToString() #Returns a string that represents the current object.
Returns
string A string that represents the current object.Inherited Methods
Properties
public string StyleId { get; } #Gets the identifier that paragraphs, runs and tables store to use this style.
public string Name { get; set; } #Gets or sets the style name shown in Word. Names are unique within a document, ignoring case.
public string? BasedOnStyleId { get; set; } #Gets or sets the identifier of the style this style inherits from.
Exceptions
ArgumentException– The base style would make this style inherit from itself.
public string? NextStyleId { get; set; } #Gets or sets the identifier of the paragraph style Word uses for the next paragraph.
public string? LinkedStyleId { get; set; } #Gets or sets the identifier of the linked style: the character style paired with a paragraph style, or the paragraph style paired with a character style.
public bool IsDefault { get; set; } #Gets or sets whether this is the default style of its type, used by content that names no style. Making a style the default clears the flag on the previous default of the same type.
public bool IsCustom { get; } #Gets whether the style was defined by a user or application rather than being built into Word.
public bool IsPrimary { get; set; } #Gets or sets whether Word shows the style in the Styles gallery.
public string? FontFamily { get; set; } #Gets or sets the font family. Reading a theme font returns the family the document theme names.
public WordThemeFont? ThemeFont { get; set; } #Gets or sets which theme font the style uses, so the text follows changes to the document theme.
public OfficeLength? FontSize { get; set; } #Gets or sets the font size, rounded to Word's half-point precision.
public OfficeColor? Color { get; set; } #Gets or sets the text colour. A theme colour reads as its current value in the document theme.
public WordThemeColor? ThemeColor { get; set; } #Gets or sets the theme colour of the text, so it follows changes to the document theme.
public WordCapsStyle? CapsStyle { get; set; } #Gets or sets capitalization: all capitals, small capitals, or explicitly neither.
public WordHighlightColor? Highlight { get; set; } #Gets or sets the highlight colour.
public WordParagraphAlignment? ParagraphAlignment { get; set; } #Gets or sets paragraph alignment.
public OfficeLength? IndentationBefore { get; set; } #Gets or sets the indentation before the text (left in left-to-right paragraphs).
public OfficeLength? IndentationAfter { get; set; } #Gets or sets the indentation after the text (right in left-to-right paragraphs).
public OfficeLength? IndentationFirstLine { get; set; } #Gets or sets the first-line indentation. Setting it removes a hanging indentation.
public OfficeLength? IndentationHanging { get; set; } #Gets or sets the hanging indentation. Setting it removes a first-line indentation.
public OfficeLength? LineSpacingBefore { get; set; } #Gets or sets the spacing before the paragraph.
public OfficeLength? LineSpacingAfter { get; set; } #Gets or sets the spacing after the paragraph.
public WordLineSpacing? LineSpacing { get; set; } #Gets or sets line spacing as a multiple, an exact height or a minimum height.
public bool? PageBreakBefore { get; set; } #Gets or sets whether paragraphs start on a new page.
public bool? KeepWithNext { get; set; } #Gets or sets whether paragraphs stay on the same page as the next paragraph.
public bool? KeepLinesTogether { get; set; } #Gets or sets whether all lines of a paragraph stay on one page.
public bool? AvoidWidowAndOrphan { get; set; } #Gets or sets widow and orphan control.
public bool? ContextualSpacing { get; set; } #Gets or sets whether spacing between paragraphs of this style is suppressed.
public bool? SuppressLineNumbers { get; set; } #Gets or sets whether line numbers are suppressed for paragraphs of this style.
public bool? SuppressAutoHyphens { get; set; } #Gets or sets whether automatic hyphenation is suppressed for paragraphs of this style.
public bool? MirrorIndents { get; set; } #Gets or sets whether the indents before and after the text are used as inside and outside indents.
public int? OutlineLevel { get; set; } #Gets or sets the outline level: 0-8 for heading levels 1-9, or 9 for body text.
public OfficeColor? ShadingFillColor { get; set; } #Gets or sets the paragraph background colour.
public WordParagraphBorders Borders { get; } #Gets the paragraph borders declared by this style.
Exceptions
InvalidOperationException– The style is a character or numbering style.
public WordList? List { get; } #Gets the list that numbers paragraphs using this style, or null.
public int? ListLevel { get; } #Gets the list level that numbers paragraphs using this style, or null.