Get styleID instead of Style name

I am looking to get the styleId which is stored in word document instead of styleName form paragraph.ParagraphFormat. I need this because when docx is converted to HTML the css styles are save with styleID instead of name and when the same html is converted to docx i need the original style id so i can map styles from source doc.

image.png (80.5 KB)

@cyrusdaru1 Unfortunately, currently, there is no public API to get styleId. I have created a feature request WORDSNET-24397. We will consider exposing this property to public API and let you know once it is available.

@cyrusdaru1 Aspose.Words does not store styleId value from the markup in the model, it is used during styles.xml parsing step as a backup in case of an empty “name”, and it is also used for style.Istd mapping. When the document is being written, styleId value is generated from the current Style.Name by removing spaces and non-alphabetic characters from the name. MS Word does the same, if we manually fix styleId in the markup, the first time the MS Word or AW document is being rewritten, styleId name is being rewritten as well.
VBA returns the same as we return in Style.Name , there is no separate API to get styleId .

The following code can be suggested to generate styleId from style name.

private string GetStyleId(string styleName)
{
    Regex makeStyleId = new Regex("[^-a-zA-Z0-9]*",
        RegexOptions.Singleline | RegexOptions.Compiled);

    string styleId = makeStyleId.Replace(styleName, string.Empty);
    return styleId != string.Empty
        ? styleId
        : "a";
}

The issue WORDSNET-24397 is closed as Won't Fix

The issues you have found earlier (filed as WORDSNET-24397) have been fixed in this Aspose.Words for .NET 23.9 update also available on NuGet.