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
280 stars 50 forks source link

Distribute columns (width) evenly in tables #64

Open GhostyIs1337 opened 1 year ago

GhostyIs1337 commented 1 year ago

Is this possible with OpenXML/this API? I haven't seen it anywhere.

https://learn.microsoft.com/en-us/office/vba/api/word.columns.distributewidth

image

PrzemyslawKlys commented 1 year ago

I don't think it exsists in the openxml:

As per:

The width of the table that autofits to "page" is 5000 (according to @hisuwh) . So to introduce this feature, we need to add 5000/numberOfColumns I guess. Someone would need to test this theory ;-)

PrzemyslawKlys commented 1 year ago

Actually, it was simpler than I thought. Added two methods, DistributeColumnsEvenly and SetWidthPercentage, which can help split the table as you want it. Haven't tested if there are specific column sizes defined, may need to be adjusted to remove specific sizing of columns when defining that. Will require testing