document: support for controlling auto-sized tables

Fixes #140
This commit is contained in:
Todd 2017-12-27 16:19:25 -06:00
parent 259724dfab
commit dcf6883ca5
3 changed files with 15 additions and 0 deletions

View File

@ -194,6 +194,8 @@ func main() {
tp.Borders().SetAll(wml.ST_BorderSingle, color.Blue, 0.5*measurement.Point)
table := doc.AddTable()
table.Properties().SetLayout(wml.ST_TblLayoutTypeFixed)
table.Properties().SetWidthPercent(90)
table.Properties().SetStyle("MyTableStyle")
look := table.Properties().TableLook()

View File

@ -63,6 +63,19 @@ func (t TableProperties) SetWidthPercent(pct float64) {
t.x.TblW.WAttr.ST_DecimalNumberOrPercent.ST_UnqualifiedPercentage = gooxml.Int64(int64(pct * 50))
}
// SetLayout controls the table layout. wml.ST_TblLayoutTypeAutofit corresponds
// to "Automatically resize to fit contents" being checked, while
// wml.ST_TblLayoutTypeFixed corresponds to it being unchecked.
func (t TableProperties) SetLayout(l wml.ST_TblLayoutType) {
// ST_TblLayoutTypeAutofit is the default
if l == wml.ST_TblLayoutTypeUnset || l == wml.ST_TblLayoutTypeAutofit {
t.x.TblLayout = nil
} else {
t.x.TblLayout = wml.NewCT_TblLayoutType()
t.x.TblLayout.TypeAttr = l
}
}
// SetAlignment sets the alignment of a table within the page.
func (t TableProperties) SetAlignment(align wml.ST_JcTable) {
if align == wml.ST_JcTableUnset {