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
261 stars 47 forks source link

Any way to implement numbered list (a., b., c., ....)? #194

Closed tmpmachine closed 4 months ago

tmpmachine commented 5 months ago

Hello, I have a requirement to create a numbered list of (a., b., c., ....).

Looking around the source code there's this unimplemented CustomListStyle and I'm not sure how to add a new custom WordListStyle. Is there any way to achieve this?

PrzemyslawKlys commented 5 months ago

I guess the easiest would be add more styles to OfficeIMO.

  1. Create list in word
  2. Open this word in Open XML SDK 2.5 Productivity Tool

image

  1. Copy AbstractNum as a style to WordListStyle following the pattern that is there
  2. Modify Enum to add new style (s)

Of course one could expand the customliststyle as well, but I haven't yet had the time to implement allowing you to assign AbstractNum to existing doc.

It actually probably is not even that hard you would just need to improve on AddList and instead of picking up style you could provide your own AbstractNum from the code:

https://github.com/EvotecIT/OfficeIMO/blob/f050884046302c0fbbb2e89d0c55c11fbb7c6ea6/OfficeIMO.Word/WordList.cs#L404-L411

Of course it would be nicer to have our own class that is a bit easier to use than what OpenXml requires.

tmpmachine commented 5 months ago

Never built a package before, so I was feeling out of options. Got it working now, I'm adding new styles. thanks!

PrzemyslawKlys commented 5 months ago

I think this needs to stay until it's completed :)

PrzemyslawKlys commented 4 months ago

I've added those additional lists. So closing this one.