diff --git a/structtable.go b/structtable.go index 8401dc2..7590c88 100644 --- a/structtable.go +++ b/structtable.go @@ -563,6 +563,7 @@ func (c *WTableCell) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type WTableCellProperties struct { XMLName xml.Name `xml:"w:tcPr,omitempty"` TableCellWidth *WTableCellWidth + VMerge *WvMerge GridSpan *WGridSpan VAlign *WVerticalAlignment TableBorders *WTableBorders `xml:"w:tcBorders"` @@ -593,6 +594,8 @@ func (r *WTableCellProperties) UnmarshalXML(d *xml.Decoder, start xml.StartEleme return err } r.TableCellWidth.Type = getAtt(tt.Attr, "type") + case "vMerge": + r.VMerge = &WvMerge{Val: getAtt(tt.Attr, "val")} case "gridSpan": r.GridSpan = new(WGridSpan) v := getAtt(tt.Attr, "val") @@ -645,6 +648,30 @@ type WTableCellWidth struct { Type string `xml:"w:type,attr"` } +// WvMerge element is used to specify whether a table cell +// should be vertically merged with the cell(s) above or below it. +// When a cell is merged, its content is merged as well. +// +// The element has a single attribute called val which +// specifies the merge behavior. Its possible values are: +// +// continue: This value indicates that the current cell is part +// of a vertically merged group of cells, but it is not the first cell +// in that group. It means that the current cell should not have its +// own content and should inherit the content of the first cell in the merged group. +// +// restart: This value indicates that the current cell is the first cell in a +// new vertically merged group of cells. It means that the current cell should +// have its own content and should be used as the topmost cell in the merged group. +// +// Note that the element is only used in table cells that are part of +// a vertically merged group. For cells that are not part of a merged group, +// this element should be omitted. +type WvMerge struct { + XMLName xml.Name `xml:"w:vMerge,omitempty"` + Val string `xml:"w:val,attr,omitempty"` +} + // WTableBorders is a structure representing the borders of a Word table. type WTableBorders struct { Top *WTableBorder `xml:"w:top,omitempty"` diff --git a/structtable_test.go b/structtable_test.go index f835aa3..8c5b8e5 100644 --- a/structtable_test.go +++ b/structtable_test.go @@ -41,6 +41,9 @@ func TestTableStructure(t *testing.T) { if err != nil { t.Fatal(err) } + tab1.TableRows[0].TableCells[0].TableCellProperties.VMerge = &WvMerge{Val: "restart"} + tab1.TableRows[1].TableCells[0].TableCellProperties.VMerge = &WvMerge{} + tab1.TableRows[2].TableCells[0].TableCellProperties.VMerge = &WvMerge{} r.Children[0].(*Drawing).Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &AAlphaModFix{Amount: 50000} r.Children[0].(*Drawing).Anchor.Graphic.GraphicData.Pic.NonVisualPicProperties.CNvPicPr.Locks = &APicLocks{NoChangeAspect: 1} r.Children[0].(*Drawing).Anchor.Graphic.GraphicData.Pic.SpPr.Xfrm.Rot = 50000