2017-08-28 20:56:18 -05:00
|
|
|
// Copyright 2017 Baliance. All rights reserved.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"baliance.com/gooxml/color"
|
|
|
|
"baliance.com/gooxml/document"
|
|
|
|
"baliance.com/gooxml/measurement"
|
|
|
|
|
2017-09-22 17:58:12 -05:00
|
|
|
wml "baliance.com/gooxml/schema/soo/wordprocessingml"
|
2017-08-28 20:56:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
doc := document.New()
|
|
|
|
|
|
|
|
table := doc.AddTable()
|
2017-08-31 19:28:11 -05:00
|
|
|
// width of the page
|
2017-09-01 18:04:03 -05:00
|
|
|
table.Properties().SetWidthPercent(100)
|
2017-08-31 19:28:11 -05:00
|
|
|
// with thick borers
|
2017-09-01 18:04:03 -05:00
|
|
|
borders := table.Properties().Borders()
|
2017-08-31 19:28:11 -05:00
|
|
|
borders.SetAll(wml.ST_BorderSingle, color.Auto, 2*measurement.Point)
|
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
row := table.AddRow()
|
2017-08-31 19:28:11 -05:00
|
|
|
run := row.AddCell().AddParagraph().AddRun()
|
|
|
|
run.AddText("Name")
|
|
|
|
run.SetHighlight(wml.ST_HighlightColorYellow)
|
2017-08-28 20:56:18 -05:00
|
|
|
row.AddCell().AddParagraph().AddRun().AddText("John Smith")
|
|
|
|
row = table.AddRow()
|
|
|
|
row.AddCell().AddParagraph().AddRun().AddText("Street Address")
|
|
|
|
row.AddCell().AddParagraph().AddRun().AddText("111 Country Road")
|
|
|
|
|
2017-08-31 19:28:11 -05:00
|
|
|
doc.AddParagraph()
|
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
table = doc.AddTable()
|
2017-08-31 19:28:11 -05:00
|
|
|
// 4 inches wide
|
2017-09-01 18:04:03 -05:00
|
|
|
table.Properties().SetWidth(4 * measurement.Inch)
|
|
|
|
borders = table.Properties().Borders()
|
2017-08-31 19:28:11 -05:00
|
|
|
// thin borders
|
2017-08-28 20:56:18 -05:00
|
|
|
borders.SetAll(wml.ST_BorderSingle, color.Auto, measurement.Zero)
|
|
|
|
|
|
|
|
row = table.AddRow()
|
2017-08-31 19:28:11 -05:00
|
|
|
cell := row.AddCell()
|
|
|
|
// column span
|
2017-09-10 10:08:50 -05:00
|
|
|
cell.Properties().SetColumnSpan(2)
|
2017-08-31 19:28:11 -05:00
|
|
|
run = cell.AddParagraph().AddRun()
|
|
|
|
run.AddText("Cells can span multiple columns")
|
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
row = table.AddRow()
|
|
|
|
row.AddCell().AddParagraph().AddRun().AddText("Street Address")
|
|
|
|
row.AddCell().AddParagraph().AddRun().AddText("111 Country Road")
|
|
|
|
|
|
|
|
doc.SaveToFile("tables.docx")
|
|
|
|
|
|
|
|
}
|