EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
289 stars 50 forks source link

Figuring out the list type #258

Open ChrisBellBO opened 1 month ago

ChrisBellBO commented 1 month ago

Hi I am trying to convert Word lists into HTML ul/ol lists. I've found IsListItem and ListItemLevel which gives me enough to figure out the structure of the list but I'm not sure how to find out if it is a numbered or bulleted list. I see AddList takes a WordListStyle parameter which looks like it might give me what I want, but that doesn't seem to be exposed anywhere. I can't find it on the underlying object either, any ideas?

PrzemyslawKlys commented 1 month ago

I am probably not exposing anything.

Document has Lists property, which is WordList List, which is where it should be exposed. The "type" of the list is not stored on paragraphs, but at completely different place which is a nightmare to track

Looking at this test:

https://github.com/EvotecIT/OfficeIMO/blob/1df69dd54abfde3fedbbe8e11eceaba7662761af/OfficeIMO.Tests/Word.Lists.cs#L374-L404

You could probably figure it out. I started exposing some things in:

But it's not yet ready

ChrisBellBO commented 1 month ago

Thanks WordParagraph has a private listNumberId and WordList has a private _numberId so I think that's how I get the list for the list item WordList has a private _abstractId which I guess is how I then get hold of the AbstractNum that holds the actual style Then things get complicated. AbstractNum can have different styles at each level so I think it probably makes sense to have the style on the list item rather than on the list?

PrzemyslawKlys commented 1 month ago

The list style is applied on the list level => as in the general ones, however each list item, depending on level may have it's own config, if the list is custom, which you can see in the linked PR.

So I guess exposing both makes sense => as in list has it's own type or custom, and then each list item would need to expose what it has