document: support for vertically merging cells

Fixes #164
This commit is contained in:
Todd 2018-03-13 08:14:22 -05:00
parent 8d6c99bcdd
commit bc4407804f
3 changed files with 23 additions and 0 deletions

View File

@ -49,9 +49,22 @@ func main() {
cell := row.AddCell()
// column span / merged cells
cell.Properties().SetColumnSpan(2)
run := cell.AddParagraph().AddRun()
run.AddText("Cells can span multiple columns")
row = table.AddRow()
cell = row.AddCell()
cell.Properties().SetVerticalMerge(wml.ST_MergeRestart)
cell.AddParagraph().AddRun().AddText("Vertical Merge")
row.AddCell().AddParagraph().AddRun().AddText("")
row = table.AddRow()
cell = row.AddCell()
cell.Properties().SetVerticalMerge(wml.ST_MergeContinue)
cell.AddParagraph().AddRun().AddText("Vertical Merge 2")
row.AddCell().AddParagraph().AddRun().AddText("")
row = table.AddRow()
row.AddCell().AddParagraph().AddRun().AddText("Street Address")
row.AddCell().AddParagraph().AddRun().AddText("111 Country Road")

View File

@ -35,6 +35,16 @@ func (c CellProperties) SetColumnSpan(cols int) {
}
}
// SetVerticalMerge controls the vertical merging of cells.
func (c CellProperties) SetVerticalMerge(mergeVal wml.ST_Merge) {
if mergeVal == wml.ST_MergeUnset {
c.x.VMerge = nil
} else {
c.x.VMerge = wml.NewCT_VMerge()
c.x.VMerge.ValAttr = mergeVal
}
}
// SetWidthAuto sets the the cell width to automatic.
func (c CellProperties) SetWidthAuto() {
c.x.TcW = wml.NewCT_TblWidth()