When generating a word document with a table, I provide the option to configure a table style name that is set by “table.StyleName = “…”;”.
Word provides a bunch of builtin table styles, and a user asked me why it did not work to specify “Tabellenraster” in my config - it did not apply to table in the resulting word document.
Here is a word screenshot:
This is a matter of translation, I have to specify the english name (which is “Table Grid”).
And this brings me to the question for you: how do I find out the available english style names? German word just shows the german styles. “Document.Styles” contains only one table style (“Table Normal”).
And this finally gave me the idea how to find out english style names.
In this situation, it would be helpful if Aspose.Words had a property “LatentStyles” containing a list of those style names. What do you think? Is this reasonable or is it too exotic?
Based on limited evidence (treat as hypothesis), here is a cautious take: Summary
Aspose.Words does not expose the latent‑style entries (the <w:lsdException> elements you see in styles.xml) through a dedicated LatentStyles collection. The built‑in table styles can be accessed in a language‑independent way via the StyleIdentifier (or TableStyle) enum, which uses the English identifiers regardless of the UI language of Word.
Why it happens
The SDK stores built‑in styles by their identifier rather than by the localized name shown in the Word UI. Therefore the same identifier works for all language versions.
The latent‑style list is part of the OpenXML package and is not wrapped by a public Aspose.Words API, so you would need to read it yourself if you really need that raw list.
What to do next
Set or query a table’s style with the enum – use StyleIdentifier.TableGrid (or the corresponding TableStyle value) to work with the built‑in “Table Grid” style.
var doc = new Aspose.Words.Document("input.docx");
var table = doc.FirstSection.Body.Tables[0];
table.StyleIdentifier = StyleIdentifier.TableGrid; language‑independent
To read the English name:
string englishName = doc.Styles[StyleIdentifier.TableGrid].Name; "Table Grid"
Enumerate all built‑in table styles – iterate over the TableStyle enum and retrieve each style’s Name.
foreach (TableStyle ts in Enum.GetValues(typeof(TableStyle)))
{
var style = doc.Styles[(StyleIdentifier)ts];
Console.WriteLine($"{ts} → {style.Name}");
}
Read the latent‑style entries manually – if you need the full list of names that appear in styles.xml, open the DOCX as a zip archive and parse the XML.
using System.IO.Compression;
using System.Xml.Linq;
using (var zip = ZipFile.OpenRead("input.docx"))
{
var entry = zip.GetEntry("word/styles.xml");
using (var stream = entry.Open())
{
var xdoc = XDocument.Load(stream);
XNamespace w = "
var latentNames = xdoc
.Descendants(w + "lsdException")
.Select(e => (string)e.Attribute(w + "name"))
.ToList();
latentNames now contains the English style names such as "Table Grid"
}
}
Proceed with your processing – for normal operations use the enum‑based approach; only fall back to manual XML extraction when you specifically need the latent‑style list.
Note: Verify the behaviour with the exact Aspose.Words version you are using, as API surface can evolve.
Please validate this behaviour with your exact SDK version and a minimal repro, as support can vary by release.
Just to close this: I found this article that provides a word document with a macro that fills a mapping table with english to german styles names. That’s exactly what I need