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
279 stars 49 forks source link

Cannot set table cell margins #116

Open kristofferjalen opened 1 year ago

kristofferjalen commented 1 year ago

I understand table cell margins should be set like this:

var tableCellMarginDefault = new TableCellMarginDefault(
   new TopMargin { Width = "21", Type = TableWidthUnitValues.Pct },
   new StartMargin { Width = "21", Type = TableWidthUnitValues.Pct },
   new BottomMargin { Width = "21", Type = TableWidthUnitValues.Pct },
   new EndMargin { Width = "21", Type = TableWidthUnitValues.Pct });

var tableProperties = new TableProperties(tableCellMarginDefault);

I cannot find a way to assign the TableProperties instance to a table though.

PrzemyslawKlys commented 1 year ago

I don't think we expose margins directly yet. We only support choosing one of the built-in styles which already have the required margins set. This needs to be added/exposed.

PrzemyslawKlys commented 1 year ago

Additional questions for it:

The more think about it, the more complicated it becomes to implement.

PrzemyslawKlys commented 1 year ago

Some documentation around this:

It seems tableCellMarginDefault is settable on the style itself. However one can use TableCellMargin to apply margins directly to specific table.

<w:tblPr>
  <w:tblCellMar>
    <w:top w:w="144" w:type="dxa"/>
    <w:left w:w="144" w:type="dxa"/>
    <w:bottom w:w="144" w:type="dxa"/>
    <w:right w:w="144" w:type="dxa"/>
  </w:tblCellMar>
  …
</w:tblPr>

We need to support both, but in different ways.