Documentation ¶
Overview ¶
Package document provides creation, reading, and writing of ECMA 376 Open Office XML documents.
Example:
doc := document.New() para := doc.AddParagraph() run := para.AddRun() run.SetText("foo") doc.SaveToFile("foo.docx")
Index ¶
- Constants
- type AnchoredDrawing
- func (a AnchoredDrawing) GetImage() (common.ImageRef, bool)
- func (a AnchoredDrawing) SetAlignment(h wml.WdST_AlignH, v wml.WdST_AlignV)
- func (a AnchoredDrawing) SetHAlignment(h wml.WdST_AlignH)
- func (a AnchoredDrawing) SetName(name string)
- func (a AnchoredDrawing) SetOffset(x, y measurement.Distance)
- func (a AnchoredDrawing) SetOrigin(h wml.WdST_RelFromH, v wml.WdST_RelFromV)
- func (a AnchoredDrawing) SetSize(w, h measurement.Distance)
- func (a AnchoredDrawing) SetTextWrapNone()
- func (a AnchoredDrawing) SetTextWrapSquare(t wml.WdST_WrapText)
- func (a AnchoredDrawing) SetVAlignment(v wml.WdST_AlignV)
- func (a AnchoredDrawing) SetXOffset(x measurement.Distance)
- func (a AnchoredDrawing) SetYOffset(y measurement.Distance)
- func (a AnchoredDrawing) X() *wml.WdAnchor
- type Bookmark
- type Cell
- type CellBorders
- func (b CellBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b CellBorders) X() *wml.CT_TcBorders
- type CellProperties
- func (c CellProperties) Borders() CellBorders
- func (c CellProperties) SetColumnSpan(cols int)
- func (c CellProperties) SetShading(shd wml.ST_Shd, foreground, fill color.Color)
- func (c CellProperties) SetVerticalAlignment(align wml.ST_VerticalJc)
- func (c CellProperties) SetVerticalMerge(mergeVal wml.ST_Merge)
- func (c CellProperties) SetWidth(d measurement.Distance)
- func (c CellProperties) SetWidthAuto()
- func (c CellProperties) SetWidthPercent(pct float64)
- func (c CellProperties) X() *wml.CT_TcPr
- type Color
- type Document
- func (d *Document) AddFooter() Footer
- func (d *Document) AddHeader() Header
- func (d Document) AddHyperlink(url string) common.Hyperlink
- func (d *Document) AddImage(i common.Image) (common.ImageRef, error)
- func (d *Document) AddParagraph() Paragraph
- func (d *Document) AddTable() Table
- func (d *Document) BodySection() Section
- func (d Document) Bookmarks() []Bookmark
- func (d *Document) Footers() []Footer
- func (d *Document) FormFields() []FormField
- func (d *Document) GetImageByRelID(relID string) (common.ImageRef, bool)
- func (d *Document) Headers() []Header
- func (d *Document) InsertParagraphAfter(relativeTo Paragraph) Paragraph
- func (d *Document) InsertParagraphBefore(relativeTo Paragraph) Paragraph
- func (d *Document) InsertTableAfter(relativeTo Paragraph) Table
- func (d *Document) InsertTableBefore(relativeTo Paragraph) Table
- func (d *Document) Paragraphs() []Paragraph
- func (d *Document) RemoveParagraph(p Paragraph)
- func (d *Document) Save(w io.Writer) error
- func (d *Document) SaveToFile(path string) error
- func (d *Document) StructuredDocumentTags() []StructuredDocumentTag
- func (d *Document) Tables() []Table
- func (d *Document) Validate() error
- func (d *Document) X() *wml.Document
- type Fonts
- type Footer
- type FormField
- type FormFieldType
- type Header
- type HyperLink
- type InlineDrawing
- type Numbering
- type NumberingDefinition
- type NumberingLevel
- func (n NumberingLevel) Properties() ParagraphStyleProperties
- func (n NumberingLevel) RunProperties() RunProperties
- func (n NumberingLevel) SetAlignment(j wml.ST_Jc)
- func (n NumberingLevel) SetFormat(f wml.ST_NumberFormat)
- func (n NumberingLevel) SetText(t string)
- func (n NumberingLevel) X() *wml.CT_Lvl
- type Paragraph
- func (p Paragraph) AddBookmark(name string) Bookmark
- func (p Paragraph) AddHyperLink() HyperLink
- func (p Paragraph) AddRun() Run
- func (p Paragraph) InsertRunAfter(relativeTo Run) Run
- func (p Paragraph) InsertRunBefore(relativeTo Run) Run
- func (p Paragraph) Properties() ParagraphProperties
- func (p Paragraph) RemoveRun(r Run)
- func (p Paragraph) Runs() []Run
- func (p Paragraph) SetNumberingDefinition(nd NumberingDefinition)
- func (p Paragraph) SetNumberingDefinitionByID(abstractNumberID int64)
- func (p Paragraph) SetNumberingLevel(listLevel int)
- func (p Paragraph) SetStyle(s string)
- func (p Paragraph) Style() string
- func (p Paragraph) X() *wml.CT_P
- type ParagraphProperties
- func (p ParagraphProperties) AddSection(t wml.ST_SectionMark) Section
- func (p ParagraphProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
- func (p ParagraphProperties) SetAlignment(align wml.ST_Jc)
- func (p ParagraphProperties) SetEndIndent(m measurement.Distance)
- func (p ParagraphProperties) SetFirstLineIndent(m measurement.Distance)
- func (p ParagraphProperties) SetHangingIndent(m measurement.Distance)
- func (p ParagraphProperties) SetHeadingLevel(idx int)
- func (p ParagraphProperties) SetKeepOnOnePage(b bool)
- func (p ParagraphProperties) SetKeepWithNext(b bool)
- func (p ParagraphProperties) SetPageBreakBefore(b bool)
- func (p ParagraphProperties) SetSpacing(before, after measurement.Distance)
- func (p ParagraphProperties) SetStartIndent(m measurement.Distance)
- func (p ParagraphProperties) SetStyle(s string)
- func (p ParagraphProperties) SetWindowControl(b bool)
- func (p ParagraphProperties) Style() string
- func (p ParagraphProperties) X() *wml.CT_PPr
- type ParagraphStyleProperties
- func (p ParagraphStyleProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
- func (p ParagraphStyleProperties) SetContextualSpacing(b bool)
- func (p ParagraphStyleProperties) SetKeepNext(b bool)
- func (p ParagraphStyleProperties) SetKeepOnOnePage(b bool)
- func (p ParagraphStyleProperties) SetLeftIndent(m measurement.Distance)
- func (p ParagraphStyleProperties) SetOutlineLevel(lvl int)
- func (p ParagraphStyleProperties) SetSpacing(before, after measurement.Distance)
- func (p ParagraphStyleProperties) X() *wml.CT_PPrGeneral
- type Row
- type RowProperties
- type Run
- func (r Run) AddBreak()
- func (r Run) AddDrawingAnchored(img common.ImageRef) (AnchoredDrawing, error)
- func (r Run) AddDrawingInline(img common.ImageRef) (InlineDrawing, error)
- func (r Run) AddField(code string)
- func (r Run) AddFieldWithFormatting(code string, fmt string, isDirty bool)
- func (r Run) AddTab()
- func (r Run) AddText(s string)
- func (r Run) Clear()
- func (r Run) ClearContent()
- func (r Run) DrawingAnchored() []AnchoredDrawing
- func (r Run) Properties() RunProperties
- func (r Run) Text() string
- func (r Run) X() *wml.CT_R
- type RunProperties
- func (r RunProperties) ClearColor()
- func (r RunProperties) Color() Color
- func (r RunProperties) Fonts() Fonts
- func (r RunProperties) IsBold() bool
- func (r RunProperties) IsItalic() bool
- func (r RunProperties) SetAllCaps(b bool)
- func (r RunProperties) SetBold(b bool)
- func (r RunProperties) SetCharacterSpacing(size measurement.Distance)
- func (r RunProperties) SetColor(c color.Color)
- func (r RunProperties) SetDoubleStrikeThrough(b bool)
- func (r RunProperties) SetEffect(e wml.ST_TextEffect)
- func (r RunProperties) SetEmboss(b bool)
- func (r RunProperties) SetFontFamily(family string)
- func (r RunProperties) SetHighlight(c wml.ST_HighlightColor)
- func (r RunProperties) SetImprint(b bool)
- func (r RunProperties) SetItalic(b bool)
- func (r RunProperties) SetKerning(size measurement.Distance)
- func (r RunProperties) SetOutline(b bool)
- func (r RunProperties) SetShadow(b bool)
- func (r RunProperties) SetSize(size measurement.Distance)
- func (r RunProperties) SetSmallCaps(b bool)
- func (r RunProperties) SetStrikeThrough(b bool)
- func (r RunProperties) SetStyle(style string)
- func (r RunProperties) SetUnderline(style wml.ST_Underline, c color.Color)
- func (r RunProperties) SetVerticalAlignment(v sharedTypes.ST_VerticalAlignRun)
- func (r RunProperties) X() *wml.CT_RPr
- type Section
- type Settings
- type StructuredDocumentTag
- type Style
- func (s Style) Name() string
- func (s Style) ParagraphProperties() ParagraphStyleProperties
- func (s Style) RunProperties() RunProperties
- func (s Style) SetBasedOn(name string)
- func (s Style) SetLinkedStyle(name string)
- func (s Style) SetName(name string)
- func (s Style) SetNextStyle(name string)
- func (s Style) SetPrimaryStyle(b bool)
- func (s Style) SetSemiHidden(b bool)
- func (s Style) SetUISortOrder(order int)
- func (s Style) SetUnhideWhenUsed(b bool)
- func (s Style) StyleID() string
- func (s Style) TableConditionalFormatting(typ wml.ST_TblStyleOverrideType) TableConditionalFormatting
- func (s Style) TableProperties() TableStyleProperties
- func (s Style) Type() wml.ST_StyleType
- func (s Style) X() *wml.CT_Style
- type Styles
- type Table
- type TableBorders
- func (b TableBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
- func (b TableBorders) X() *wml.CT_TblBorders
- type TableConditionalFormatting
- type TableLook
- type TableProperties
- func (t TableProperties) Borders() TableBorders
- func (t TableProperties) SetAlignment(align wml.ST_JcTable)
- func (t TableProperties) SetCellSpacing(m measurement.Distance)
- func (t TableProperties) SetCellSpacingAuto()
- func (t TableProperties) SetCellSpacingPercent(pct float64)
- func (t TableProperties) SetLayout(l wml.ST_TblLayoutType)
- func (t TableProperties) SetStyle(name string)
- func (t TableProperties) SetWidth(d measurement.Distance)
- func (t TableProperties) SetWidthAuto()
- func (t TableProperties) SetWidthPercent(pct float64)
- func (t TableProperties) TableLook() TableLook
- func (t TableProperties) X() *wml.CT_TblPr
- type TableStyleProperties
- func (t TableStyleProperties) Borders() TableBorders
- func (t TableStyleProperties) SetCellSpacingAuto()
- func (t TableStyleProperties) SetCellSpacingPercent(pct float64)
- func (t TableStyleProperties) SetColumnBandSize(cols int64)
- func (t TableStyleProperties) SetRowBandSize(rows int64)
- func (t TableStyleProperties) SetTableIndent(ind measurement.Distance)
- func (t TableStyleProperties) X() *wml.CT_TblPrBase
- type TableWidth
Examples ¶
Constants ¶
const ( FieldCurrentPage = "PAGE" FieldNumberOfPages = "NUMPAGES" FieldDate = "DATE" FieldCreateDate = "CREATEDATE" FieldEditTime = "EDITTIME" FieldPrintDate = "PRINTDATE" FieldSaveDate = "SAVEDATE" FieldTIme = "TIME" FieldTOC = "TOC" )
Field constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnchoredDrawing ¶
type AnchoredDrawing struct {
// contains filtered or unexported fields
}
AnchoredDrawing is an absolutely positioned image within a document page.
func (AnchoredDrawing) GetImage ¶
func (a AnchoredDrawing) GetImage() (common.ImageRef, bool)
GetImage returns the ImageRef associated with an AnchoredDrawing.
func (AnchoredDrawing) SetAlignment ¶
func (a AnchoredDrawing) SetAlignment(h wml.WdST_AlignH, v wml.WdST_AlignV)
SetAlignment positions an anchored image via alignment. Offset is incompatible with SetOffset, whichever is called last is applied.
func (AnchoredDrawing) SetHAlignment ¶
func (a AnchoredDrawing) SetHAlignment(h wml.WdST_AlignH)
SetHAlignment sets the horizontal alignment for an anchored image.
func (AnchoredDrawing) SetName ¶
func (a AnchoredDrawing) SetName(name string)
SetName sets the name of the image, visible in the properties of the image within Word.
func (AnchoredDrawing) SetOffset ¶
func (a AnchoredDrawing) SetOffset(x, y measurement.Distance)
SetOffset sets the offset of the image relative to the origin, which by default this is the top-left corner of the page. Offset is incompatible with SetAlignment, whichever is called last is applied.
func (AnchoredDrawing) SetOrigin ¶
func (a AnchoredDrawing) SetOrigin(h wml.WdST_RelFromH, v wml.WdST_RelFromV)
SetOrigin sets the origin of the image. It defaults to ST_RelFromHPage and ST_RelFromVPage
func (AnchoredDrawing) SetSize ¶
func (a AnchoredDrawing) SetSize(w, h measurement.Distance)
SetSize sets the size of the displayed image on the page.
func (AnchoredDrawing) SetTextWrapNone ¶
func (a AnchoredDrawing) SetTextWrapNone()
SetTextWrapNone unsets text wrapping so the image can float on top of the text. When used in conjunction with X/Y Offset relative to the page it can be used to place a logo at the top of a page at an absolute position that doesn't interfere with text.
func (AnchoredDrawing) SetTextWrapSquare ¶
func (a AnchoredDrawing) SetTextWrapSquare(t wml.WdST_WrapText)
SetTextWrapSquare sets the text wrap to square with a given wrap type.
func (AnchoredDrawing) SetVAlignment ¶
func (a AnchoredDrawing) SetVAlignment(v wml.WdST_AlignV)
SetVAlignment sets the vertical alignment for an anchored image.
func (AnchoredDrawing) SetXOffset ¶
func (a AnchoredDrawing) SetXOffset(x measurement.Distance)
SetXOffset sets the X offset for an image relative to the origin.
func (AnchoredDrawing) SetYOffset ¶
func (a AnchoredDrawing) SetYOffset(y measurement.Distance)
SetYOffset sets the Y offset for an image relative to the origin.
func (AnchoredDrawing) X ¶
func (a AnchoredDrawing) X() *wml.WdAnchor
X returns the inner wrapped XML type.
type Bookmark ¶ added in v0.6.0
type Bookmark struct {
// contains filtered or unexported fields
}
Bookmark is a bookmarked location within a document that can be referenced with a hyperlink.
func (Bookmark) Name ¶ added in v0.6.0
Name returns the name of the bookmark whcih is the document unique ID that identifies the bookmark.
func (Bookmark) SetName ¶ added in v0.6.0
SetName sets the name of the bookmark. This is the name that is used to reference the bookmark from hyperlinks.
func (Bookmark) X ¶ added in v0.6.0
func (b Bookmark) X() *wml.CT_Bookmark
X returns the inner wrapped XML type.
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell is a table cell within a document (not a spreadsheet)
func (Cell) AddParagraph ¶
AddParagraph adds a paragraph to the table cell.
func (Cell) Paragraphs ¶ added in v0.7.0
Paragraphs returns the paragraphs defined in the cell.
func (Cell) Properties ¶
func (c Cell) Properties() CellProperties
Properties returns the cell properties.
type CellBorders ¶ added in v0.6.0
type CellBorders struct {
// contains filtered or unexported fields
}
CellBorders are the borders for an individual
func (CellBorders) SetAll ¶ added in v0.6.0
func (b CellBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetAll sets all of the borders to a given value.
func (CellBorders) SetBottom ¶ added in v0.6.0
func (b CellBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBottom sets the bottom border to a specified type, color and thickness.
func (CellBorders) SetInsideHorizontal ¶ added in v0.6.0
func (b CellBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
func (CellBorders) SetInsideVertical ¶ added in v0.6.0
func (b CellBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func (CellBorders) SetLeft ¶ added in v0.6.0
func (b CellBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetLeft sets the left border to a specified type, color and thickness.
func (CellBorders) SetRight ¶ added in v0.6.0
func (b CellBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetRight sets the right border to a specified type, color and thickness.
func (CellBorders) SetTop ¶ added in v0.6.0
func (b CellBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetTop sets the top border to a specified type, color and thickness.
func (CellBorders) X ¶ added in v0.6.0
func (b CellBorders) X() *wml.CT_TcBorders
X returns the inner wrapped type
type CellProperties ¶
type CellProperties struct {
// contains filtered or unexported fields
}
CellProperties are a table cells properties within a document.
func (CellProperties) Borders ¶ added in v0.6.0
func (c CellProperties) Borders() CellBorders
Borders allows controlling individual cell borders.
func (CellProperties) SetColumnSpan ¶
func (c CellProperties) SetColumnSpan(cols int)
SetColumnSpan sets the number of Grid Columns Spanned by the Cell. This is used to give the appearance of merged cells.
func (CellProperties) SetShading ¶ added in v0.6.0
func (c CellProperties) SetShading(shd wml.ST_Shd, foreground, fill color.Color)
SetShading controls the cell shading.
func (CellProperties) SetVerticalAlignment ¶ added in v0.6.0
func (c CellProperties) SetVerticalAlignment(align wml.ST_VerticalJc)
SetVerticalAlignment sets the vertical alignment of content within a table cell.
func (CellProperties) SetVerticalMerge ¶ added in v0.7.0
func (c CellProperties) SetVerticalMerge(mergeVal wml.ST_Merge)
SetVerticalMerge controls the vertical merging of cells.
func (CellProperties) SetWidth ¶ added in v0.6.0
func (c CellProperties) SetWidth(d measurement.Distance)
SetWidth sets the cell width to a specified width.
func (CellProperties) SetWidthAuto ¶ added in v0.6.0
func (c CellProperties) SetWidthAuto()
SetWidthAuto sets the the cell width to automatic.
func (CellProperties) SetWidthPercent ¶ added in v0.6.0
func (c CellProperties) SetWidthPercent(pct float64)
SetWidthPercent sets the cell to a width percentage.
func (CellProperties) X ¶
func (c CellProperties) X() *wml.CT_TcPr
X returns the inner wrapped XML type.
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color controls the run or styles color.
func (Color) SetColor ¶
SetColor sets a specific color or auto.
func (Color) SetThemeColor ¶
func (c Color) SetThemeColor(t wml.ST_ThemeColor)
SetThemeColor sets the color from the theme.
func (Color) SetThemeShade ¶
SetThemeShade sets the shade based off the theme color.
type Document ¶
type Document struct { common.DocBase Settings Settings // document settings Numbering Numbering // numbering styles within the doucment Styles Styles // styles that are use and can be used within the document // contains filtered or unexported fields }
Document is a text document that can be written out in the OOXML .docx format. It can be opened from a file on disk and modified, or created from scratch.
func New ¶
func New() *Document
New constructs an empty document that content can be added to.
Example ¶
package main import ( "baliance.com/gooxml/document" ) func main() { doc := document.New() doc.AddParagraph().AddRun().AddText("Hello World!") doc.SaveToFile("document.docx") }
Output:
func Open ¶
Open opens and reads a document from a file (.docx).
Example ¶
package main import ( "fmt" "log" "baliance.com/gooxml/document" ) func main() { doc, err := document.Open("existing.docx") if err != nil { log.Fatalf("error opening document: %s", err) } for _, para := range doc.Paragraphs() { for _, run := range para.Runs() { fmt.Print(run.Text()) } fmt.Println() } }
Output:
func OpenTemplate ¶
OpenTemplate opens a document, removing all content so it can be used as a template. Since Word removes unused styles from a document upon save, to create a template in Word add a paragraph with every style of interest. When opened with OpenTemplate the document's styles will be available but the content will be gone.
Example ¶
package main import ( "log" "baliance.com/gooxml/document" ) func main() { doc, err := document.OpenTemplate("existing.docx") if err != nil { log.Fatalf("error opening document template: %s", err) } para := doc.AddParagraph() para.SetStyle("Title") para.AddRun().AddText("My Document Title") para = doc.AddParagraph() para.SetStyle("Subtitle") para.AddRun().AddText("Document Subtitle") para = doc.AddParagraph() para.SetStyle("Heading1") para.AddRun().AddText("Major Section") doc.SaveToFile("ouput.docx") }
Output:
func Read ¶
Read reads a document from an io.Reader.
func (*Document) AddFooter ¶
AddFooter creates a Footer associated with the document, but doesn't add it to the document for display.
func (*Document) AddHeader ¶
AddHeader creates a header associated with the document, but doesn't add it to the document for display.
func (Document) AddHyperlink ¶ added in v0.6.0
AddHyperlink adds a hyperlink to a document. Adding the hyperlink to a document and setting it on a cell is more efficient than setting hyperlinks directly on a cell.
func (*Document) AddImage ¶
AddImage adds an image to the document package, returning a reference that can be used to add the image to a run and place it in the document contents.
func (*Document) AddParagraph ¶
AddParagraph adds a new paragraph to the document body.
func (*Document) AddTable ¶
AddTable adds a new table to the document body.
func (*Document) BodySection ¶
BodySection returns the default body section used for all preceding paragraphs until the previous Section. If there is no previous sections, the body section applies to the entire document.
func (Document) Bookmarks ¶ added in v0.6.0
Bookmarks returns all of the bookmarks defined in the document.
func (*Document) Footers ¶ added in v0.6.0
Footers returns the footers defined in the document.
func (*Document) FormFields ¶
FormFields extracts all of the fields from a document. They can then be manipulated via the methods on the field and the document saved.
Example ¶
package main import ( "log" "baliance.com/gooxml/document" ) func main() { doc, err := document.Open("invitation.docx") if err != nil { log.Fatalf("error opening document form: %s", err) } for _, field := range doc.FormFields() { switch field.Name() { case "attendingEvent": if field.Type() == document.FormFieldTypeCheckBox { field.SetChecked(true) } case "name": if field.Type() == document.FormFieldTypeText { field.SetValue("John Smith") } } } doc.SaveToFile("invitation-respoonse.docx") }
Output:
func (*Document) GetImageByRelID ¶
GetImageByRelID returns an ImageRef with the associated relation ID in the document.
func (*Document) Headers ¶ added in v0.6.0
Headers returns the headers defined in the document.
func (*Document) InsertParagraphAfter ¶ added in v0.4.0
InsertParagraphAfter adds a new empty paragraph after the relativeTo paragraph.
func (*Document) InsertParagraphBefore ¶ added in v0.4.0
InsertParagraphBefore adds a new empty paragraph before the relativeTo paragraph.
func (*Document) InsertTableAfter ¶ added in v0.7.1
func (*Document) InsertTableBefore ¶ added in v0.7.1
func (*Document) Paragraphs ¶
Paragraphs returns all of the paragraphs in the document body.
func (*Document) RemoveParagraph ¶ added in v0.6.0
RemoveParagraph removes a paragraph from a document.
func (*Document) Save ¶
Save writes the document to an io.Writer in the Zip package format.
func (*Document) SaveToFile ¶
SaveToFile writes the document out to a file.
func (*Document) StructuredDocumentTags ¶ added in v0.4.0
func (d *Document) StructuredDocumentTags() []StructuredDocumentTag
StructuredDocumentTags returns the structured document tags in the document which are commonly used in document templates.
func (*Document) Tables ¶ added in v0.7.0
Tables returns the tables defined in the document.
func (*Document) Validate ¶
Validate validates the structure and in cases where it't possible, the ranges of elements within a document. A validation error dones't mean that the document won't work in MS Word or LibreOffice, but it's worth checking into.
type Fonts ¶
type Fonts struct {
// contains filtered or unexported fields
}
Fonts allows manipulating a style or run's fonts.
func (Fonts) SetASCIITheme ¶
SetASCIITheme sets the font ASCII Theme.
func (Fonts) SetCSTheme ¶
SetCSTheme sets the font complex script theme.
func (Fonts) SetEastAsiaTheme ¶
SetEastAsiaTheme sets the font East Asia Theme.
func (Fonts) SetHANSITheme ¶
SetHANSITheme sets the font H ANSI Theme.
type Footer ¶
type Footer struct {
// contains filtered or unexported fields
}
Footer is a footer for a document section.
func (Footer) AddParagraph ¶
AddParagraph adds a paragraph to the footer.
func (Footer) Clear ¶ added in v0.6.0
func (f Footer) Clear()
Clear clears all content within a footer
func (Footer) Index ¶
Index returns the index of the footer within the document. This is used to form its zip packaged filename as well as to match it with its relationship ID.
func (Footer) Paragraphs ¶ added in v0.6.0
Paragraphs returns the paragraphs defined in a footer.
func (Footer) RemoveParagraph ¶ added in v0.6.0
RemoveParagraph removes a paragraph from a footer.
type FormField ¶
type FormField struct {
// contains filtered or unexported fields
}
FormField is a form within a document. It references the document, so changes to the form field wil be reflected in the document if it is saved.
func (FormField) IsChecked ¶
IsChecked returns true if a FormFieldTypeCheckBox is checked.
func (FormField) PossibleValues ¶
PossibleValues returns the possible values for a FormFieldTypeDropDown.
func (FormField) SetChecked ¶
SetChecked marks a FormFieldTypeCheckBox as checked or unchecked.
func (FormField) SetValue ¶
SetValue sets the value of a FormFieldTypeText or FormFieldTypeDropDown. For FormFieldTypeDropDown, the value must be one of the fields possible values.
type FormFieldType ¶
type FormFieldType byte
FormFieldType is the type of the form field.
const ( FormFieldTypeUnknown FormFieldType = iota FormFieldTypeText FormFieldTypeCheckBox FormFieldTypeDropDown )
Form Field Type constants
func (FormFieldType) String ¶
func (i FormFieldType) String() string
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is a header for a document section.
func (Header) AddImage ¶ added in v0.6.0
AddImage adds an image to the document package, returning a reference that can be used to add the image to a run and place it in the document contents.
func (Header) AddParagraph ¶
AddParagraph adds a paragraph to the header.
func (Header) Clear ¶ added in v0.6.0
func (h Header) Clear()
Clear clears all content within a header
func (Header) Index ¶
Index returns the index of the header within the document. This is used to form its zip packaged filename as well as to match it with its relationship ID.
func (Header) Paragraphs ¶ added in v0.6.0
Paragraphs returns the paragraphs defined in a header.
func (Header) RemoveParagraph ¶ added in v0.6.0
RemoveParagraph removes a paragraph from a footer.
type HyperLink ¶ added in v0.6.0
type HyperLink struct {
// contains filtered or unexported fields
}
HyperLink is a link within a document.
func (HyperLink) AddRun ¶ added in v0.6.0
AddRun adds a run of text to a hyperlink. This is the text that will be linked.
func (HyperLink) SetTarget ¶ added in v0.6.0
SetTarget sets the URL target of the hyperlink.
func (HyperLink) SetTargetBookmark ¶ added in v0.6.0
SetTargetBookmark sets the bookmark target of the hyperlink.
func (HyperLink) SetTargetByRef ¶ added in v0.6.0
SetTargetByRef sets the URL target of the hyperlink and is more efficient if a link destination will be used many times.
func (HyperLink) SetToolTip ¶ added in v0.6.0
SetToolTip sets the tooltip text for a hyperlink.
func (HyperLink) X ¶ added in v0.6.0
func (h HyperLink) X() *wml.CT_Hyperlink
X returns the inner wrapped XML type.
type InlineDrawing ¶ added in v0.6.0
type InlineDrawing struct {
// contains filtered or unexported fields
}
InlineDrawing is an inlined image within a run.
func (InlineDrawing) GetImage ¶ added in v0.6.0
func (i InlineDrawing) GetImage() (common.ImageRef, bool)
GetImage returns the ImageRef associated with an InlineDrawing.
func (InlineDrawing) SetSize ¶ added in v0.6.0
func (i InlineDrawing) SetSize(w, h measurement.Distance)
SetSize sets the size of the displayed image on the page.
func (InlineDrawing) X ¶ added in v0.6.0
func (i InlineDrawing) X() *wml.WdInline
X returns the inner wrapped XML type.
type Numbering ¶
type Numbering struct {
// contains filtered or unexported fields
}
Numbering is the document wide numbering styles contained in numbering.xml.
func (Numbering) AddDefinition ¶ added in v0.6.0
func (n Numbering) AddDefinition() NumberingDefinition
AddDefinition adds a new numbering definition.
func (Numbering) Definitions ¶ added in v0.6.0
func (n Numbering) Definitions() []NumberingDefinition
Definitions returns the defined numbering definitions.
type NumberingDefinition ¶ added in v0.6.0
type NumberingDefinition struct {
// contains filtered or unexported fields
}
NumberingDefinition defines a numbering definition for a list of pragraphs.
func (NumberingDefinition) AbstractNumberID ¶ added in v0.6.0
func (n NumberingDefinition) AbstractNumberID() int64
AbstractNumberID returns the ID that is unique within all numbering definitions that is used to assign the definition to a paragraph.
func (NumberingDefinition) AddLevel ¶ added in v0.6.0
func (n NumberingDefinition) AddLevel() NumberingLevel
AddLevel adds a new numbering level to a NumberingDefinition.
func (NumberingDefinition) Levels ¶ added in v0.6.0
func (n NumberingDefinition) Levels() []NumberingLevel
Levels returns all of the numbering levels defined in the definition.
func (NumberingDefinition) X ¶ added in v0.6.0
func (n NumberingDefinition) X() *wml.CT_AbstractNum
X returns the inner wrapped XML type.
type NumberingLevel ¶ added in v0.6.0
type NumberingLevel struct {
// contains filtered or unexported fields
}
NumberingLevel is the definition for numbering for a particular level within a NumberingDefinition.
func (NumberingLevel) Properties ¶ added in v0.6.0
func (n NumberingLevel) Properties() ParagraphStyleProperties
Properties returns the numbering level paragraph properties.
func (NumberingLevel) RunProperties ¶ added in v0.6.0
func (n NumberingLevel) RunProperties() RunProperties
RunProperties returns the RunProperties controlling numbering level font, etc.
func (NumberingLevel) SetAlignment ¶ added in v0.6.0
func (n NumberingLevel) SetAlignment(j wml.ST_Jc)
SetAlignment sets the paragraph alignment
func (NumberingLevel) SetFormat ¶ added in v0.6.0
func (n NumberingLevel) SetFormat(f wml.ST_NumberFormat)
SetFormat sets the numbering format.
func (NumberingLevel) SetText ¶ added in v0.6.0
func (n NumberingLevel) SetText(t string)
SetText sets the text to be used in bullet mode.
func (NumberingLevel) X ¶ added in v0.6.0
func (n NumberingLevel) X() *wml.CT_Lvl
X returns the inner wrapped XML type.
type Paragraph ¶
type Paragraph struct {
// contains filtered or unexported fields
}
Paragraph is a paragraph within a document.
func (Paragraph) AddBookmark ¶ added in v0.6.0
AddBookmark adds a bookmark to a document that can then be used from a hyperlink. Name is a document unique name that identifies the bookmark so it can be referenced from hyperlinks.
func (Paragraph) AddHyperLink ¶ added in v0.6.0
AddHyperLink adds a new hyperlink to a parapgraph.
func (Paragraph) InsertRunAfter ¶ added in v0.4.0
InsertRunAfter inserts a run in the paragraph after the relative run.
func (Paragraph) InsertRunBefore ¶ added in v0.4.0
InsertRunBefore inserts a run in the paragraph before the relative run.
func (Paragraph) Properties ¶
func (p Paragraph) Properties() ParagraphProperties
Properties returns the paragraph properties.
func (Paragraph) RemoveRun ¶ added in v0.6.0
RemoveRun removes a child run from a paragraph.
func (Paragraph) Runs ¶
Runs returns all of the runs in a paragraph.
func (Paragraph) SetNumberingDefinition ¶ added in v0.6.0
func (p Paragraph) SetNumberingDefinition(nd NumberingDefinition)
SetNumberingDefinition sets the numbering definition ID via a NumberingDefinition defined in numbering.xml
func (Paragraph) SetNumberingDefinitionByID ¶ added in v0.6.0
SetNumberingDefinitionByID sets the numbering definition ID directly, which must match an ID defined in numbering.xml
func (Paragraph) SetNumberingLevel ¶ added in v0.6.0
SetNumberingLevel sets the numbering level of a paragraph. If used, then the NumberingDefinition must also be set via SetNumberingDefinition or SetNumberingDefinitionByID.
func (Paragraph) SetStyle ¶
SetStyle sets the style of a paragraph and is identical to setting it on the paragraph's Properties()
func (Paragraph) Style ¶
Style returns the style for a paragraph, or an empty string if it is unset.
type ParagraphProperties ¶
type ParagraphProperties struct {
// contains filtered or unexported fields
}
ParagraphProperties are the properties for a paragraph.
func (ParagraphProperties) AddSection ¶
func (p ParagraphProperties) AddSection(t wml.ST_SectionMark) Section
AddSection adds a new document section with an optional section break. If t is ST_SectionMarkUnset, then no break will be inserted.
func (ParagraphProperties) AddTabStop ¶
func (p ParagraphProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
AddTabStop adds a tab stop to the paragraph. It controls the position of text when using Run.AddTab()
func (ParagraphProperties) SetAlignment ¶ added in v0.6.0
func (p ParagraphProperties) SetAlignment(align wml.ST_Jc)
SetAlignment controls the paragraph alignment
func (ParagraphProperties) SetEndIndent ¶ added in v0.6.0
func (p ParagraphProperties) SetEndIndent(m measurement.Distance)
SetEndIndent controls the end indentation.
func (ParagraphProperties) SetFirstLineIndent ¶ added in v0.6.0
func (p ParagraphProperties) SetFirstLineIndent(m measurement.Distance)
SetFirstLineIndent controls the indentation of the first line in a paragraph.
func (ParagraphProperties) SetHangingIndent ¶ added in v0.6.0
func (p ParagraphProperties) SetHangingIndent(m measurement.Distance)
SetHangingIndent controls the indentation of the non-first lines in a paragraph.
func (ParagraphProperties) SetHeadingLevel ¶
func (p ParagraphProperties) SetHeadingLevel(idx int)
SetHeadingLevel sets a heading level and style based on the level to a paragraph. The default styles for a new gooxml document support headings from level 1 to 8.
func (ParagraphProperties) SetKeepOnOnePage ¶
func (p ParagraphProperties) SetKeepOnOnePage(b bool)
SetKeepOnOnePage controls if all lines in a paragraph are kept on the same page.
func (ParagraphProperties) SetKeepWithNext ¶
func (p ParagraphProperties) SetKeepWithNext(b bool)
SetKeepWithNext controls if this paragraph should be kept with the next.
func (ParagraphProperties) SetPageBreakBefore ¶
func (p ParagraphProperties) SetPageBreakBefore(b bool)
SetPageBreakBefore controls if there is a page break before this paragraph.
func (ParagraphProperties) SetSpacing ¶
func (p ParagraphProperties) SetSpacing(before, after measurement.Distance)
SetSpacing sets the spacing that comes before and after the paragraph.
func (ParagraphProperties) SetStartIndent ¶ added in v0.6.0
func (p ParagraphProperties) SetStartIndent(m measurement.Distance)
SetStartIndent controls the start indentation.
func (ParagraphProperties) SetStyle ¶
func (p ParagraphProperties) SetStyle(s string)
SetStyle sets the style of a paragraph.
func (ParagraphProperties) SetWindowControl ¶
func (p ParagraphProperties) SetWindowControl(b bool)
SetWindowControl controls if the first or last line of the paragraph is allowed to dispay on a separate page.
func (ParagraphProperties) Style ¶
func (p ParagraphProperties) Style() string
Style returns the style for a paragraph, or an empty string if it is unset.
func (ParagraphProperties) X ¶
func (p ParagraphProperties) X() *wml.CT_PPr
X returns the inner wrapped XML type.
type ParagraphStyleProperties ¶
type ParagraphStyleProperties struct {
// contains filtered or unexported fields
}
ParagraphStyleProperties is the styling information for a paragraph.
func (ParagraphStyleProperties) AddTabStop ¶
func (p ParagraphStyleProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader wml.ST_TabTlc)
AddTabStop adds a tab stop to the paragraph.
func (ParagraphStyleProperties) SetContextualSpacing ¶
func (p ParagraphStyleProperties) SetContextualSpacing(b bool)
SetContextualSpacing controls whether to Ignore Spacing Above and Below When Using Identical Styles
func (ParagraphStyleProperties) SetKeepNext ¶
func (p ParagraphStyleProperties) SetKeepNext(b bool)
SetKeepNext controls if the paragraph is kept with the next paragraph.
func (ParagraphStyleProperties) SetKeepOnOnePage ¶
func (p ParagraphStyleProperties) SetKeepOnOnePage(b bool)
SetKeepOnOnePage controls if all lines in a paragraph are kept on the same page.
func (ParagraphStyleProperties) SetLeftIndent ¶ added in v0.6.0
func (p ParagraphStyleProperties) SetLeftIndent(m measurement.Distance)
SetLeftIndent controls the left indent of the paragraph.
func (ParagraphStyleProperties) SetOutlineLevel ¶
func (p ParagraphStyleProperties) SetOutlineLevel(lvl int)
SetOutlineLevel sets the outline level of this style.
func (ParagraphStyleProperties) SetSpacing ¶
func (p ParagraphStyleProperties) SetSpacing(before, after measurement.Distance)
SetSpacing sets the spacing that comes before and after the paragraph.
func (ParagraphStyleProperties) X ¶
func (p ParagraphStyleProperties) X() *wml.CT_PPrGeneral
X returns the inner wrapped XML type.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row is a row within a table within a document.
func (Row) Cells ¶ added in v0.7.0
Cells returns the cells defined in the table.
func (Row) Properties ¶ added in v0.6.0
func (r Row) Properties() RowProperties
Properties returns the row properties.
type RowProperties ¶ added in v0.6.0
type RowProperties struct {
// contains filtered or unexported fields
}
RowProperties are the properties for a row within a table
func (RowProperties) SetHeight ¶ added in v0.6.0
func (r RowProperties) SetHeight(ht measurement.Distance, rule wml.ST_HeightRule)
SetHeight allows controlling the height of a row within a table.
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run is a run of text within a paragraph that shares the same formatting.
func (Run) AddDrawingAnchored ¶
func (r Run) AddDrawingAnchored(img common.ImageRef) (AnchoredDrawing, error)
AddDrawingAnchored adds an anchored (floating) drawing from an ImageRef.
func (Run) AddDrawingInline ¶ added in v0.6.0
func (r Run) AddDrawingInline(img common.ImageRef) (InlineDrawing, error)
AddDrawingInline adds an inline drawing from an ImageRef.
func (Run) AddField ¶
AddField adds a field (automatically computed text) to the document.
func (Run) AddFieldWithFormatting ¶
AddFieldWithFormatting adds a field (automatically computed text) to the document with field specifc formatting.
func (Run) AddTab ¶
func (r Run) AddTab()
AddTab adds tab to a run and can be used with the the Paragraph's tab stops.
func (Run) Clear ¶ added in v0.6.0
func (r Run) Clear()
Clear removes all of the content from within a run.
func (Run) ClearContent ¶ added in v0.4.0
func (r Run) ClearContent()
ClearContent clears any content in the run (text, tabs, breaks, etc.)
func (Run) DrawingAnchored ¶
func (r Run) DrawingAnchored() []AnchoredDrawing
DrawingAnchored returns a slice of AnchoredDrawings.
func (Run) Properties ¶ added in v0.6.0
func (r Run) Properties() RunProperties
Properties returns the run properties.
type RunProperties ¶ added in v0.6.0
type RunProperties struct {
// contains filtered or unexported fields
}
RunProperties controls run styling properties
func (RunProperties) ClearColor ¶ added in v0.6.0
func (r RunProperties) ClearColor()
ClearColor clears the text color.
func (RunProperties) Color ¶ added in v0.6.0
func (r RunProperties) Color() Color
Color returns the style's Color.
func (RunProperties) Fonts ¶ added in v0.6.0
func (r RunProperties) Fonts() Fonts
Fonts returns the style's Fonts.
func (RunProperties) IsBold ¶ added in v0.6.0
func (r RunProperties) IsBold() bool
IsBold returns true if the run has been set to bold.
func (RunProperties) IsItalic ¶ added in v0.6.0
func (r RunProperties) IsItalic() bool
IsItalic returns true if the run was set to bold.
func (RunProperties) SetAllCaps ¶ added in v0.6.0
func (r RunProperties) SetAllCaps(b bool)
SetAllCaps sets the run to all caps.
func (RunProperties) SetBold ¶ added in v0.6.0
func (r RunProperties) SetBold(b bool)
SetBold sets the run to bold.
func (RunProperties) SetCharacterSpacing ¶ added in v0.6.0
func (r RunProperties) SetCharacterSpacing(size measurement.Distance)
SetCharacterSpacing sets the run's Character Spacing Adjustment.
func (RunProperties) SetColor ¶ added in v0.6.0
func (r RunProperties) SetColor(c color.Color)
SetColor sets the text color.
func (RunProperties) SetDoubleStrikeThrough ¶ added in v0.6.0
func (r RunProperties) SetDoubleStrikeThrough(b bool)
SetDoubleStrikeThrough sets the run to double strike-through.
func (RunProperties) SetEffect ¶ added in v0.6.0
func (r RunProperties) SetEffect(e wml.ST_TextEffect)
SetEffect sets a text effect on the run.
func (RunProperties) SetEmboss ¶ added in v0.6.0
func (r RunProperties) SetEmboss(b bool)
SetEmboss sets the run to embossed text.
func (RunProperties) SetFontFamily ¶ added in v0.6.0
func (r RunProperties) SetFontFamily(family string)
SetFontFamily sets the Ascii & HAnsi fonly family for a run.
func (RunProperties) SetHighlight ¶ added in v0.6.0
func (r RunProperties) SetHighlight(c wml.ST_HighlightColor)
SetHighlight highlights text in a specified color.
func (RunProperties) SetImprint ¶ added in v0.6.0
func (r RunProperties) SetImprint(b bool)
SetImprint sets the run to imprinted text.
func (RunProperties) SetItalic ¶ added in v0.6.0
func (r RunProperties) SetItalic(b bool)
SetItalic sets the run to italic.
func (RunProperties) SetKerning ¶ added in v0.6.0
func (r RunProperties) SetKerning(size measurement.Distance)
SetKerning sets the run's font kerning.
func (RunProperties) SetOutline ¶ added in v0.6.0
func (r RunProperties) SetOutline(b bool)
SetOutline sets the run to outlined text.
func (RunProperties) SetShadow ¶ added in v0.6.0
func (r RunProperties) SetShadow(b bool)
SetShadow sets the run to shadowed text.
func (RunProperties) SetSize ¶ added in v0.6.0
func (r RunProperties) SetSize(size measurement.Distance)
SetSize sets the font size for a run.
func (RunProperties) SetSmallCaps ¶ added in v0.6.0
func (r RunProperties) SetSmallCaps(b bool)
SetSmallCaps sets the run to small caps.
func (RunProperties) SetStrikeThrough ¶ added in v0.6.0
func (r RunProperties) SetStrikeThrough(b bool)
SetStrikeThrough sets the run to strike-through.
func (RunProperties) SetStyle ¶ added in v0.6.0
func (r RunProperties) SetStyle(style string)
SetStyle sets the font size.
func (RunProperties) SetUnderline ¶ added in v0.6.0
func (r RunProperties) SetUnderline(style wml.ST_Underline, c color.Color)
SetUnderline controls underline for a run style.
func (RunProperties) SetVerticalAlignment ¶ added in v0.6.0
func (r RunProperties) SetVerticalAlignment(v sharedTypes.ST_VerticalAlignRun)
SetVerticalAlignment controls the vertical alignment of the run, this is used to control if text is superscript/subscript.
func (RunProperties) X ¶ added in v0.6.0
func (r RunProperties) X() *wml.CT_RPr
X returns the inner wrapped XML type.
type Section ¶
type Section struct {
// contains filtered or unexported fields
}
Section is the beginning of a new section.
func (Section) SetFooter ¶
SetFooter sets a section footer.
func (Section) SetHeader ¶
SetHeader sets a section header.
func (Section) SetPageMargins ¶ added in v0.7.0
func (s Section) SetPageMargins(top, right, bottom, left, header, footer, gutter measurement.Distance)
SetPageMargins sets the page margins for a section
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings controls the document settings.
func (Settings) SetUpdateFieldsOnOpen ¶
SetUpdateFieldsOnOpen controls if fields are recalculated upon opening the document. This is useful for things like a table of contents as the library only adds the field code and relies on Word/LibreOffice to actually compute the content.
type StructuredDocumentTag ¶ added in v0.4.0
type StructuredDocumentTag struct {
// contains filtered or unexported fields
}
StructuredDocumentTag are a tagged bit of content in a document.
func (StructuredDocumentTag) Paragraphs ¶ added in v0.4.0
func (s StructuredDocumentTag) Paragraphs() []Paragraph
Paragraphs returns the paragraphs within a structured document tag.
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style is a style within the styles.xml file.
func (Style) ParagraphProperties ¶
func (s Style) ParagraphProperties() ParagraphStyleProperties
ParagraphProperties returns the paragraph style properties.
func (Style) RunProperties ¶
func (s Style) RunProperties() RunProperties
RunProperties returns the run style properties.
func (Style) SetBasedOn ¶
SetBasedOn sets the style that this style is based on.
func (Style) SetLinkedStyle ¶
SetLinkedStyle sets the style that this style is linked to.
func (Style) SetNextStyle ¶
SetNextStyle sets the style that the next paragraph will use.
func (Style) SetPrimaryStyle ¶
SetPrimaryStyle marks the style as a primary style.
func (Style) SetSemiHidden ¶
SetSemiHidden controls if the style is hidden in the UI.
func (Style) SetUISortOrder ¶
SetUISortOrder controls the order the style is displayed in the UI.
func (Style) SetUnhideWhenUsed ¶
SetUnhideWhenUsed controls if a semi hidden style becomes visible when used.
func (Style) TableConditionalFormatting ¶ added in v0.6.0
func (s Style) TableConditionalFormatting(typ wml.ST_TblStyleOverrideType) TableConditionalFormatting
TableConditionalFormatting returns a conditional formatting object of a given type. Calling this method repeatedly will return the same object.
func (Style) TableProperties ¶ added in v0.6.0
func (s Style) TableProperties() TableStyleProperties
TableProperties returns the table style properties.
type Styles ¶
type Styles struct {
// contains filtered or unexported fields
}
Styles is the document wide styles contained in styles.xml.
func (Styles) AddStyle ¶
AddStyle adds a new empty style.
func (Styles) InitializeDefault ¶
func (s Styles) InitializeDefault()
InitializeDefault constructs the default styles.
func (Styles) ParagraphStyles ¶
ParagraphStyles returns only the paragraph styles.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a table within a document.
func (Table) Properties ¶
func (t Table) Properties() TableProperties
Properties returns the table properties.
func (Table) Rows ¶ added in v0.7.0
Rows returns the rows defined in the table.
type TableBorders ¶
type TableBorders struct {
// contains filtered or unexported fields
}
TableBorders allows manipulation of borders on a table.
func (TableBorders) SetAll ¶
func (b TableBorders) SetAll(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetAll sets all of the borders to a given value.
func (TableBorders) SetBottom ¶
func (b TableBorders) SetBottom(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetBottom sets the bottom border to a specified type, color and thickness.
func (TableBorders) SetInsideHorizontal ¶
func (b TableBorders) SetInsideHorizontal(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideHorizontal sets the interior horizontal borders to a specified type, color and thickness.
func (TableBorders) SetInsideVertical ¶
func (b TableBorders) SetInsideVertical(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetInsideVertical sets the interior vertical borders to a specified type, color and thickness.
func (TableBorders) SetLeft ¶
func (b TableBorders) SetLeft(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetLeft sets the left border to a specified type, color and thickness.
func (TableBorders) SetRight ¶
func (b TableBorders) SetRight(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetRight sets the right border to a specified type, color and thickness.
func (TableBorders) SetTop ¶
func (b TableBorders) SetTop(t wml.ST_Border, c color.Color, thickness measurement.Distance)
SetTop sets the top border to a specified type, color and thickness.
func (TableBorders) X ¶
func (b TableBorders) X() *wml.CT_TblBorders
X returns the inner wml.CT_TblBorders
type TableConditionalFormatting ¶ added in v0.6.0
type TableConditionalFormatting struct {
// contains filtered or unexported fields
}
TableConditionalFormatting controls the conditional formatting within a table style.
func (TableConditionalFormatting) CellProperties ¶ added in v0.6.0
func (t TableConditionalFormatting) CellProperties() CellProperties
CellProperties returns the cell properties.
func (TableConditionalFormatting) ParagraphProperties ¶ added in v0.6.0
func (t TableConditionalFormatting) ParagraphProperties() ParagraphStyleProperties
ParagraphProperties returns the paragraph properties controlling text formatting within the table.
func (TableConditionalFormatting) RunProperties ¶ added in v0.6.0
func (t TableConditionalFormatting) RunProperties() RunProperties
RunProperties returns the run properties controlling text formatting within the table.
func (TableConditionalFormatting) X ¶ added in v0.6.0
func (t TableConditionalFormatting) X() *wml.CT_TblStylePr
X returns the inner wrapped XML type.
type TableLook ¶ added in v0.6.0
type TableLook struct {
// contains filtered or unexported fields
}
TableLook is the conditional formatting associated with a table style that has been assigned to a table.
func (TableLook) SetFirstColumn ¶ added in v0.6.0
SetFirstColumn controls the conditional formatting for the first column in a table.
func (TableLook) SetFirstRow ¶ added in v0.6.0
SetFirstRow controls the conditional formatting for the first row in a table.
func (TableLook) SetHorizontalBanding ¶ added in v0.6.0
SetHorizontalBanding controls the conditional formatting for horizontal banding.
func (TableLook) SetLastColumn ¶ added in v0.6.0
SetLastColumn controls the conditional formatting for the last column in a table.
func (TableLook) SetLastRow ¶ added in v0.6.0
SetLastRow controls the conditional formatting for the last row in a table. This is called the 'Total' row within Word.
func (TableLook) SetVerticalBanding ¶ added in v0.6.0
SetVerticalBanding controls the conditional formatting for vertical banding.
func (TableLook) X ¶ added in v0.6.0
func (t TableLook) X() *wml.CT_TblLook
X returns the inner wrapped XML type.
type TableProperties ¶
type TableProperties struct {
// contains filtered or unexported fields
}
TableProperties are the properties for a table within a document
func (TableProperties) Borders ¶
func (t TableProperties) Borders() TableBorders
Borders allows manipulation of the table borders.
func (TableProperties) SetAlignment ¶ added in v0.6.0
func (t TableProperties) SetAlignment(align wml.ST_JcTable)
SetAlignment sets the alignment of a table within the page.
func (TableProperties) SetCellSpacing ¶
func (t TableProperties) SetCellSpacing(m measurement.Distance)
SetCellSpacing sets the cell spacing within a table.
func (TableProperties) SetCellSpacingAuto ¶
func (t TableProperties) SetCellSpacingAuto()
SetCellSpacingAuto sets the cell spacing within a table to automatic.
func (TableProperties) SetCellSpacingPercent ¶
func (t TableProperties) SetCellSpacingPercent(pct float64)
SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func (TableProperties) SetLayout ¶ added in v0.6.0
func (t TableProperties) SetLayout(l wml.ST_TblLayoutType)
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 (TableProperties) SetStyle ¶ added in v0.6.0
func (t TableProperties) SetStyle(name string)
SetStyle sets the table style name.
func (TableProperties) SetWidth ¶
func (t TableProperties) SetWidth(d measurement.Distance)
SetWidth sets the table with to a specified width.
func (TableProperties) SetWidthAuto ¶
func (t TableProperties) SetWidthAuto()
SetWidthAuto sets the the table width to automatic.
func (TableProperties) SetWidthPercent ¶
func (t TableProperties) SetWidthPercent(pct float64)
SetWidthPercent sets the table to a width percentage.
func (TableProperties) TableLook ¶ added in v0.6.0
func (t TableProperties) TableLook() TableLook
TableLook returns the table look, or conditional formatting applied to a table style.
func (TableProperties) X ¶
func (t TableProperties) X() *wml.CT_TblPr
X returns the inner wrapped XML type.
type TableStyleProperties ¶ added in v0.6.0
type TableStyleProperties struct {
// contains filtered or unexported fields
}
TableStyleProperties are table properties as defined in a style.
func (TableStyleProperties) Borders ¶ added in v0.6.0
func (t TableStyleProperties) Borders() TableBorders
Borders allows manipulation of the table borders.
func (TableStyleProperties) SetCellSpacingAuto ¶ added in v0.6.0
func (t TableStyleProperties) SetCellSpacingAuto()
SetCellSpacingAuto sets the cell spacing within a table to automatic.
func (TableStyleProperties) SetCellSpacingPercent ¶ added in v0.6.0
func (t TableStyleProperties) SetCellSpacingPercent(pct float64)
SetCellSpacingPercent sets the cell spacing within a table to a percent width.
func (TableStyleProperties) SetColumnBandSize ¶ added in v0.6.0
func (t TableStyleProperties) SetColumnBandSize(cols int64)
SetColumnBandSize sets the number of Columns in the column band
func (TableStyleProperties) SetRowBandSize ¶ added in v0.6.0
func (t TableStyleProperties) SetRowBandSize(rows int64)
SetRowBandSize sets the number of Rows in the row band
func (TableStyleProperties) SetTableIndent ¶ added in v0.6.0
func (t TableStyleProperties) SetTableIndent(ind measurement.Distance)
SetTableIndent sets the Table Indent from the Leading Margin
func (TableStyleProperties) X ¶ added in v0.6.0
func (t TableStyleProperties) X() *wml.CT_TblPrBase
X returns the inner wrapped XML type.
type TableWidth ¶
type TableWidth struct {
// contains filtered or unexported fields
}
TableWidth controls width values in table settings.
func NewTableWidth ¶
func NewTableWidth() TableWidth
NewTableWidth returns a newly intialized TableWidth
func (TableWidth) SetValue ¶
func (s TableWidth) SetValue(m measurement.Distance)
SetValue sets the width value.
func (TableWidth) X ¶
func (s TableWidth) X() *wml.CT_TblWidth
X returns the inner wrapped XML type.
Source Files ¶
- anchoreddrawing.go
- bookmark.go
- cell.go
- cellborders.go
- cellproperties.go
- color.go
- doc.go
- document.go
- fonts.go
- footer.go
- formfield.go
- formfieldtype_string.go
- header.go
- hyperlink.go
- inlinedrawing.go
- knownfields.go
- numbering.go
- numberingdefinition.go
- numberinglevel.go
- paragraph.go
- paragraphproperties.go
- paragraphstyleproperties.go
- row.go
- rowproperties.go
- run.go
- runproperties.go
- section.go
- settings.go
- structuredocumenttag.go
- style.go
- styles.go
- table.go
- tableborders.go
- tableconditionalformatting.go
- tableproperties.go
- tablestyleproperties.go
- tablewidth.go
- tbllook.go