Documentation
¶
Overview ¶
Package docx is one of the most functional libraries to read and write .docx (a.k.a. Microsoft Word documents or ECMA-376 Office Open XML) files in Go.
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func GetInt(s string) (int, error)
- func GetInt64(s string) (int64, error)
- func MergeAllRuns(_, _ *Run) bool
- func MergeSamePropRuns(r1, r2 *Run) bool
- func StringToBytes(s string) (b []byte)
- type AAlphaModFix
- type ABlip
- type ABlipFill
- type AExt
- type AFillRect
- type AGraphic
- type AGraphicData
- type AGraphicFrameLocks
- type AGroupShapeLocks
- type AHeadEnd
- type ALine
- type AMiter
- type AOff
- type APITableBorderColors
- type APicLocks
- type APrstDash
- type APrstGeom
- type ASPLocks
- type ASolidFill
- type ASrcRect
- type ASrgbClr
- type AStretch
- type ATailEnd
- type ATile
- type AXfrm
- type AdjustRightInd
- type BarterRabbet
- type Body
- type Bold
- type Color
- type Cols
- type DocGrid
- type Document
- type Docx
- func (f *Docx) AddParagraph() *Paragraph
- func (f *Docx) AddTable(row int, col int, tableWidth int64, borderColors *APITableBorderColors) *Table
- func (f *Docx) AddTableTwips(rowHeights []int64, colWidths []int64, tableWidth int64, ...) *Table
- func (f *Docx) AppendFile(af *Docx)
- func (f *Docx) IncreaseID(name string) (n uintptr)
- func (f *Docx) Media(name string) *Media
- func (f *Docx) RangeRelationships(iter func(*Relationship) error) error
- func (f *Docx) Read(_ []byte) (int, error)
- func (f *Docx) ReferID(target string) (string, error)
- func (f *Docx) ReferTarget(id string) (string, error)
- func (f *Docx) SplitByParagraph(separator ParagraphSplitRule) (docs []*Docx)
- func (f *Docx) UseTemplate(template string, tmpfslst []string, tmplfs fs.FS) *Docx
- func (f *Docx) WithA3Page() *Docx
- func (f *Docx) WithA4Page() *Docx
- func (f *Docx) WithDefaultTheme() *Docx
- func (f *Docx) WriteTo(writer io.Writer) (_ int64, err error)
- type Drawing
- type Highlight
- type Hyperlink
- type Ilevel
- type Ind
- type Italic
- type Justification
- type Kern
- type Kinsoku
- type Media
- type NonVisualProperties
- type NumId
- type NumProperties
- type OverflowPunct
- type PICBlipFill
- type PICNonVisualPicProperties
- type PICSpPr
- type Paragraph
- func (p *Paragraph) AddAnchorDrawing(pic []byte) (*Run, error)
- func (p *Paragraph) AddAnchorDrawingFrom(file string) (*Run, error)
- func (p *Paragraph) AddAnchorShape(w, h int64, name, bwMode, prst string, ln *ALine) *Run
- func (p *Paragraph) AddInlineDrawing(pic []byte) (*Run, error)
- func (p *Paragraph) AddInlineDrawingFrom(file string) (*Run, error)
- func (p *Paragraph) AddInlineShape(w, h int64, name, bwMode, prst string, ln *ALine) *Run
- func (p *Paragraph) AddLink(text string, link string) *Hyperlink
- func (p *Paragraph) AddPageBreaks() *Run
- func (p *Paragraph) AddTab() *Run
- func (p *Paragraph) AddText(text string) *Run
- func (p *Paragraph) DropCanvas()
- func (p *Paragraph) DropGroup()
- func (p *Paragraph) DropNilPicture()
- func (p *Paragraph) DropShape()
- func (p *Paragraph) DropShapeAndCanvas()
- func (p *Paragraph) DropShapeAndCanvasAndGroup()
- func (p *Paragraph) Justification(val string) *Paragraph
- func (p *Paragraph) KeepElements(name ...string)
- func (p *Paragraph) MergeText(canmerge RunMergeRule) (np Paragraph)
- func (p *Paragraph) NumFont(ascii, eastAsia, hansi, hint string) *Paragraph
- func (p *Paragraph) NumPr(numId, ilvl string) *Paragraph
- func (p *Paragraph) NumSize(size string) *Paragraph
- func (p *Paragraph) String() string
- func (p *Paragraph) Style(val string) *Paragraph
- func (p *Paragraph) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
- type ParagraphProperties
- type ParagraphSplitRule
- type PgMar
- type PgSz
- type PicCNvPicPr
- type Picture
- type Relationship
- type Relationships
- type Run
- func (r *Run) AddTab() *Run
- func (r *Run) Bold() *Run
- func (r *Run) Color(color string) *Run
- func (r *Run) Font(ascii, eastAsia, hansi, hint string) *Run
- func (r *Run) Highlight(val string) *Run
- func (r *Run) Italic() *Run
- func (r *Run) KeepElements(name ...string)
- func (r *Run) Shade(val, color, fill string) *Run
- func (r *Run) Size(size string) *Run
- func (r *Run) SizeCs(size string) *Run
- func (r *Run) Spacing(line int) *Run
- func (r *Run) Strike(val bool) *Run
- func (r *Run) Underline(val string) *Run
- func (r *Run) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type RunFonts
- type RunMergeRule
- type RunProperties
- type RunStyle
- type SectPr
- type Shade
- type ShapeProperties
- type Size
- type SizeCs
- type SnapToGrid
- type Spacing
- type Strike
- type Style
- type Tab
- type Table
- type Tabs
- type Text
- type TextAlignment
- type Underline
- type VertAlign
- type WGridCol
- type WGridSpan
- type WPAnchor
- type WPCBackground
- type WPCNvGraphicFramePr
- type WPCWhole
- type WPDocPr
- type WPEffectExtent
- type WPExtent
- type WPGGroupShape
- type WPGcNvGrpSpPr
- type WPInline
- type WPPositionH
- type WPPositionV
- type WPSBodyPr
- type WPSCNvCnPr
- type WPSCNvSpPr
- type WPSTextBox
- type WPSimplePos
- type WPWrapSquare
- type WTableBorder
- type WTableBorders
- type WTableCell
- type WTableCellProperties
- type WTableCellWidth
- type WTableGrid
- type WTableLook
- type WTablePositioningProperties
- type WTableProperties
- type WTableRow
- type WTableRowHeight
- type WTableRowProperties
- type WTableStyle
- type WTableWidth
- type WTextBoxContent
- type WVerticalAlignment
- type WordprocessingCanvas
- type WordprocessingGroup
- type WordprocessingShape
- type WvMerge
Constants ¶
const ( XMLNS_W = `http://schemas.openxmlformats.org/wordprocessingml/2006/main` XMLNS_R = `http://schemas.openxmlformats.org/officeDocument/2006/relationships` XMLNS_WP = `http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing` XMLNS_WPS = `http://schemas.microsoft.com/office/word/2010/wordprocessingShape` XMLNS_WPC = `http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas` XMLNS_WPG = `http://schemas.microsoft.com/office/word/2010/wordprocessingGroup` XMLNS_MC = `http://schemas.openxmlformats.org/markup-compatibility/2006` XMLNS_O = `urn:schemas-microsoft-com:office:office` XMLNS_V = `urn:schemas-microsoft-com:vml` XMLNS_PICTURE = `http://schemas.openxmlformats.org/drawingml/2006/picture` )
const ( XMLNS_DRAWINGML_MAIN = `http://schemas.openxmlformats.org/drawingml/2006/main` XMLNS_DRAWINGML_PICTURE = `http://schemas.openxmlformats.org/drawingml/2006/picture` )
const ( XMLNS_REL = `http://schemas.openxmlformats.org/package/2006/relationships` REL_HYPERLINK = `http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink` REL_IMAGE = `http://schemas.openxmlformats.org/officeDocument/2006/relationships/image` REL_TARGETMODE = "External" )
const (
// A4_EMU_MAX_WIDTH is the max display width of an A4 paper
A4_EMU_MAX_WIDTH = 5274310
)
const (
HYPERLINK_STYLE = "a3"
)
const MEDIA_FOLDER = `word/media/`
Variables ¶
var ( // TemplateXMLFS stores template docx files //go:embed xml //go:embed xml/default/_rels/* TemplateXMLFS embed.FS // DefaultTemplateFilesList is the files list under TemplateXMLFS/xml/default DefaultTemplateFilesList = []string{ "_rels/.rels", "docProps/app.xml", "docProps/core.xml", "word/theme/theme1.xml", "word/fontTable.xml", "word/styles.xml", "[Content_Types].xml", } )
var ( // ErrRefIDNotFound cannot find such reference ErrRefIDNotFound = errors.New("ref id not found") // ErrRefTargetNotFound cannot find such target ErrRefTargetNotFound = errors.New("ref target not found") )
Functions ¶
func MergeSamePropRuns ¶
MergeSamePropRuns merges runs with the same properties
Types ¶
type AAlphaModFix ¶
type AAlphaModFix struct { XMLName xml.Name `xml:"a:alphaModFix,omitempty"` Amount int `xml:"amt,attr"` }
AAlphaModFix ...
type ABlip ¶
type ABlip struct { XMLName xml.Name `xml:"a:blip,omitempty"` Embed string `xml:"r:embed,attr"` Cstate string `xml:"cstate,attr,omitempty"` AlphaModFix *AAlphaModFix }
ABlip represents the blip of a picture in a Word document.
func (*ABlip) UnmarshalXML ¶
UnmarshalXML ...
type ABlipFill ¶
type ABlipFill struct { XMLName xml.Name `xml:"a:blipFill,omitempty"` DPI int `xml:"dpi,attr"` RotWithShape int `xml:"rotWithShape,attr"` Blip *ABlip SrcRect *ASrcRect Tile *ATile }
ABlipFill represents a fill that contains a reference to an image.
func (*ABlipFill) UnmarshalXML ¶
UnmarshalXML ...
type AExt ¶
AExt is a struct representing the <a:ext> / <a:chExt> element in OpenXML, which describes the size of a shape.
type AGraphic ¶
type AGraphic struct { XMLName xml.Name `xml:"a:graphic,omitempty"` XMLA string `xml:"xmlns:a,attr,omitempty"` GraphicData *AGraphicData // contains filtered or unexported fields }
AGraphic represents a graphic in a Word document.
func (*AGraphic) UnmarshalXML ¶
UnmarshalXML ...
type AGraphicData ¶
type AGraphicData struct { XMLName xml.Name `xml:"a:graphicData,omitempty"` URI string `xml:"uri,attr"` Pic *Picture Shape *WordprocessingShape Canvas *WordprocessingCanvas Group *WordprocessingGroup // contains filtered or unexported fields }
AGraphicData represents the data of a graphic in a Word document.
func (*AGraphicData) UnmarshalXML ¶
func (a *AGraphicData) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type AGraphicFrameLocks ¶
type AGraphicFrameLocks struct { XMLName xml.Name `xml:"a:graphicFrameLocks,omitempty"` XMLA string `xml:"xmlns:a,attr,omitempty"` NoChangeAspect int `xml:"noChangeAspect,attr,omitempty"` }
AGraphicFrameLocks represents the locks applied to a graphic frame.
type AGroupShapeLocks ¶
AGroupShapeLocks represents the locks applied to a group shape.
type AHeadEnd ¶
type AHeadEnd struct { XMLName xml.Name `xml:"a:headEnd,omitempty"` Type string `xml:"type,attr,omitempty"` W string `xml:"w,attr,omitempty"` Len string `xml:"len,attr,omitempty"` }
AHeadEnd ...
func (*AHeadEnd) UnmarshalXML ¶
UnmarshalXML ...
type ALine ¶
type ALine struct { XMLName xml.Name `xml:"a:ln,omitempty"` W int64 `xml:"w,attr,omitempty"` Cap string `xml:"cap,attr,omitempty"` Compound string `xml:"cmpd,attr,omitempty"` Align string `xml:"algn,attr,omitempty"` NoFill *struct{} `xml:"a:noFill,omitempty"` SolidFill *ASolidFill PrstDash *APrstDash Miter *AMiter Round *struct{} `xml:"a:round,omitempty"` HeadEnd *AHeadEnd TailEnd *ATailEnd }
ALine represents a line element in a Word document.
func (*ALine) UnmarshalXML ¶
UnmarshalXML ...
type AOff ¶
AOff is a struct representing the <a:off> / <a:chOff> element in OpenXML, which describes the offset of a shape from its original position.
type APITableBorderColors ¶
type APITableBorderColors struct { Top string Left string Bottom string Right string InsideH string InsideV string }
APITableBorderColors customizable param
type APicLocks ¶
type APicLocks struct { XMLName xml.Name `xml:"a:picLocks,omitempty"` NoChangeAspect int `xml:"noChangeAspect,attr"` }
APicLocks represents the locks applied to a picture.
type APrstGeom ¶
type APrstGeom struct { XMLName xml.Name `xml:"a:prstGeom,omitempty"` Prst string `xml:"prst,attr"` AvLst *struct{} `xml:"a:avLst,omitempty"` }
APrstGeom is a struct representing the <a:prstGeom> element in OpenXML, which describes the preset shape geometry for a shape.
func (*APrstGeom) UnmarshalXML ¶
UnmarshalXML ...
type ASPLocks ¶
type ASPLocks struct { XMLName xml.Name `xml:"a:spLocks,omitempty"` NoChangeArrowheads int `xml:"noChangeArrowheads,attr,omitempty"` }
ASPLocks represents the locks applied to a shape.
func (*ASPLocks) UnmarshalXML ¶
UnmarshalXML ...
type ASolidFill ¶
ASolidFill represents a solid fill of a shape or chart element.
func (*ASolidFill) UnmarshalXML ¶
func (s *ASolidFill) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type ATailEnd ¶
type ATailEnd struct { XMLName xml.Name `xml:"a:tailEnd,omitempty"` Type string `xml:"type,attr,omitempty"` W string `xml:"w,attr,omitempty"` Len string `xml:"len,attr,omitempty"` }
ATailEnd ...
func (*ATailEnd) UnmarshalXML ¶
UnmarshalXML ...
type ATile ¶
type ATile struct { XMLName xml.Name `xml:"a:tile,omitempty"` TX int64 `xml:"tx,attr"` TY int64 `xml:"ty,attr"` SX int64 `xml:"sx,attr"` SY int64 `xml:"sy,attr"` Flip string `xml:"flip,attr"` Algn string `xml:"algn,attr"` }
ATile represents the tiling information of a fill or border
func (*ATile) UnmarshalXML ¶
UnmarshalXML ...
type AXfrm ¶
type AXfrm struct { XMLName xml.Name `xml:"a:xfrm,omitempty"` Rot int64 `xml:"rot,attr,omitempty"` FlipH int `xml:"flipH,attr,omitempty"` FlipV int `xml:"flipV,attr,omitempty"` Off AOff `xml:"a:off,omitempty"` Ext AExt `xml:"a:ext,omitempty"` ChOff *AOff `xml:"a:chOff,omitempty"` ChExt *AExt `xml:"a:chExt,omitempty"` }
AXfrm is a struct representing the <a:xfrm> element in OpenXML, which describes the position and size of a shape.
func (*AXfrm) UnmarshalXML ¶
UnmarshalXML ...
type AdjustRightInd ¶
type AdjustRightInd struct { XMLName xml.Name `xml:"w:adjustRightInd,omitempty"` Val int `xml:"w:val,attr"` }
AdjustRightInd ...
type BarterRabbet ¶
type BarterRabbet struct { XMLName xml.Name `xml:"w:br,omitempty"` Type string `xml:"w:type,attr,omitempty"` }
BarterRabbet is <br> , if with type=page , add pagebreaks
func (*BarterRabbet) UnmarshalXML ¶
func (f *BarterRabbet) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type Body ¶
type Body struct { Items []interface{} // contains filtered or unexported fields }
Body <w:body>
func (*Body) DropDrawingOf ¶
DropDrawingOf drops all matched drawing in body name: Canvas, Shape, Group, ShapeAndCanvas, ShapeAndCanvasAndGroup, NilPicture
func (*Body) KeepElements ¶
KeepElements keep named elems amd removes others
names: *docx.Paragraph *docx.Table
func (*Body) UnmarshalXML ¶
UnmarshalXML ...
type Cols ¶
type Cols struct {
Space int `xml:"w:space,attr"`
}
Cols show the number of columns
func (*Cols) UnmarshalXML ¶
UnmarshalXML ...
type Document ¶
type Document struct { XMLName xml.Name `xml:"w:document"` XMLW string `xml:"xmlns:w,attr"` // cannot be unmarshalled in XMLR string `xml:"xmlns:r,attr,omitempty"` // cannot be unmarshalled in XMLWP string `xml:"xmlns:wp,attr,omitempty"` // cannot be unmarshalled in XMLWPS string `xml:"xmlns:wps,attr,omitempty"` // cannot be unmarshalled in XMLWPC string `xml:"xmlns:wpc,attr,omitempty"` // cannot be unmarshalled in XMLWPG string `xml:"xmlns:wpg,attr,omitempty"` // cannot be unmarshalled in Body Body `xml:"w:body"` }
Document <w:document>
func (*Document) UnmarshalXML ¶
UnmarshalXML ...
type Docx ¶
type Docx struct { Document Document // Document is word/document.xml io.Reader io.WriterTo // contains filtered or unexported fields }
Docx is the structure that allow to access the internal represntation in memory of the doc (either read or about to be written)
func LoadBodyItems ¶
LoadBodyItems will load body and media to a new Docx struct. You should call UseTemplate to set a template later.
func New ¶
func New() *Docx
New generates a new empty docx file that we can manipulate and later on, save
func Parse ¶
Parse generates a new docx file in memory from a reader You can it invoke from a file
readFile, err := os.Open(FILE_PATH) if err != nil { panic(err) } fileinfo, err := readFile.Stat() if err != nil { panic(err) } size := fileinfo.Size() doc, err := docxlib.Parse(readFile, int64(size))
but also you can invoke from a webform (BEWARE of trusting users data!!!)
func uploadFile(w http.ResponseWriter, r *http.Request) { r.ParseMultipartForm(10 << 20) file, handler, err := r.FormFile("file") if err != nil { fmt.Println("Error Retrieving the File") fmt.Println(err) http.Error(w, err.Error(), http.StatusBadRequest) return } defer file.Close() docxlib.Parse(file, handler.Size) }
func (*Docx) AddParagraph ¶
AddParagraph adds a new paragraph
func (*Docx) AddTable ¶
func (f *Docx) AddTable( row int, col int, tableWidth int64, borderColors *APITableBorderColors, ) *Table
AddTable add a new table to body by col*row
unit: twips (1/20 point)
func (*Docx) AddTableTwips ¶
func (f *Docx) AddTableTwips( rowHeights []int64, colWidths []int64, tableWidth int64, borderColors *APITableBorderColors, ) *Table
AddTableTwips add a new table to body by height and width
unit: twips (1/20 point)
func (*Docx) AppendFile ¶
AppendFile appends all contents in af to f
func (*Docx) RangeRelationships ¶
func (f *Docx) RangeRelationships(iter func(*Relationship) error) error
RangeRelationships goes through each doc relation
func (*Docx) ReferTarget ¶
ReferTarget gets the target for a reference
func (*Docx) SplitByParagraph ¶
func (f *Docx) SplitByParagraph(separator ParagraphSplitRule) (docs []*Docx)
SplitByParagraph splits a doc to many docs by using a matched paragraph as the separator.
The separator will be placed to the first doc item
func (*Docx) UseTemplate ¶
UseTemplate will replace template files
func (*Docx) WithDefaultTheme ¶
WithDefaultTheme use default theme embeded
type Drawing ¶
type Drawing struct { XMLName xml.Name `xml:"w:drawing,omitempty"` Inline *WPInline Anchor *WPAnchor // contains filtered or unexported fields }
Drawing element contains photos
func (*Drawing) UnmarshalXML ¶
UnmarshalXML ...
type Highlight ¶
type Highlight struct { XMLName xml.Name `xml:"w:highlight,omitempty"` Val string `xml:"w:val,attr,omitempty"` }
Highlight ...
type Hyperlink ¶
type Hyperlink struct { XMLName xml.Name `xml:"w:hyperlink,omitempty"` ID string `xml:"r:id,attr"` Run Run }
Hyperlink element contains links
func (*Hyperlink) UnmarshalXML ¶
UnmarshalXML ...
type Ind ¶
type Ind struct { XMLName xml.Name `xml:"w:ind,omitempty"` LeftChars int `xml:"w:leftChars,attr,omitempty"` Left int `xml:"w:left,attr,omitempty"` FirstLineChars int `xml:"w:firstLineChars,attr,omitempty"` FirstLine int `xml:"w:firstLine,attr,omitempty"` HangingChars int `xml:"w:hangingChars,attr,omitempty"` Hanging int `xml:"w:hanging,attr,omitempty"` }
Ind ...
func (*Ind) UnmarshalXML ¶
UnmarshalXML ...
type Justification ¶
Justification contains the way of the horizonal alignment
w:jc 属性的取值可以是以下之一: start:左对齐。 center:居中对齐。 end:右对齐。 both:两端对齐。 distribute:分散对齐。
type Media ¶
type Media struct { Name string // Name is for word/media/Name Data []byte // Data is data of this media }
Media is in word/media
type NonVisualProperties ¶
NonVisualProperties is an element that represents the non-visual properties of a content control.
func (*NonVisualProperties) UnmarshalXML ¶
func (r *NonVisualProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
UnmarshalXML ...
type NumProperties ¶
NumProperties show the number properties
func (*NumProperties) UnmarshalXML ¶
func (n *NumProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type OverflowPunct ¶
type OverflowPunct struct { XMLName xml.Name `xml:"w:overflowPunct,omitempty"` Val int `xml:"w:val,attr"` }
OverflowPunct ...
type PICBlipFill ¶
type PICBlipFill struct { XMLName xml.Name `xml:"pic:blipFill,omitempty"` Blip ABlip Stretch AStretch }
PICBlipFill represents the blip fill of a picture in a Word document.
func (*PICBlipFill) UnmarshalXML ¶
func (p *PICBlipFill) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type PICNonVisualPicProperties ¶
type PICNonVisualPicProperties struct { XMLName xml.Name `xml:"pic:nvPicPr,omitempty"` NonVisualDrawingProperties NonVisualProperties `xml:"pic:cNvPr,omitempty"` CNvPicPr PicCNvPicPr }
PICNonVisualPicProperties represents the non-visual properties of a picture in a Word document.
func (*PICNonVisualPicProperties) UnmarshalXML ¶
func (p *PICNonVisualPicProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type PICSpPr ¶
PICSpPr is a struct representing the <pic:spPr> element in OpenXML, which describes the shape properties for a picture.
func (*PICSpPr) UnmarshalXML ¶
UnmarshalXML ...
type Paragraph ¶
type Paragraph struct { XMLName xml.Name `xml:"w:p,omitempty"` Properties *ParagraphProperties Children []interface{} // contains filtered or unexported fields }
Paragraph <w:p>
func (*Paragraph) AddAnchorDrawing ¶
AddAnchorDrawing adds inline drawing to paragraph
func (*Paragraph) AddAnchorDrawingFrom ¶
AddAnchorDrawingFrom adds drawing from file to paragraph
func (*Paragraph) AddAnchorShape ¶
AddAnchorShape adds wsp named drawing to paragraph
func (*Paragraph) AddInlineDrawing ¶
AddInlineDrawing adds inline drawing to paragraph
func (*Paragraph) AddInlineDrawingFrom ¶
AddInlineDrawingFrom adds drawing from file to paragraph
func (*Paragraph) AddInlineShape ¶
AddInlineShape adds wsp named drawing to paragraph
func (*Paragraph) AddPageBreaks ¶
AddPageBreaks adds a pagebreaks
func (*Paragraph) DropCanvas ¶
func (p *Paragraph) DropCanvas()
DropCanvas drops all canvases in paragraph
func (*Paragraph) DropGroup ¶
func (p *Paragraph) DropGroup()
DropGroup drops all groups in paragraph
func (*Paragraph) DropNilPicture ¶
func (p *Paragraph) DropNilPicture()
DropNilPicture drops all drawings with nil picture in paragraph
func (*Paragraph) DropShape ¶
func (p *Paragraph) DropShape()
DropShape drops all shapes in paragraph
func (*Paragraph) DropShapeAndCanvas ¶
func (p *Paragraph) DropShapeAndCanvas()
DropShapeAndCanvas drops all shapes and canvases in paragraph
func (*Paragraph) DropShapeAndCanvasAndGroup ¶
func (p *Paragraph) DropShapeAndCanvasAndGroup()
DropShapeAndCanvasAndGroup drops all shapes, canvases and groups in paragraph
func (*Paragraph) Justification ¶
Justification allows to set para's horizonal alignment
w:jc 属性的取值可以是以下之一: start:左对齐。 center:居中对齐。 end:右对齐。 both:两端对齐。 distribute:分散对齐。
func (*Paragraph) KeepElements ¶
KeepElements keep named elems amd removes others
names: *docx.Hyperlink *docx.Run *docx.RunProperties
func (*Paragraph) MergeText ¶
func (p *Paragraph) MergeText(canmerge RunMergeRule) (np Paragraph)
MergeText will merge contiguous run texts in a paragraph into one run
note: np is not a deep-copy
func (*Paragraph) UnmarshalXML ¶
UnmarshalXML ...
type ParagraphProperties ¶
type ParagraphProperties struct { XMLName xml.Name `xml:"w:pPr,omitempty"` Tabs *Tabs Spacing *Spacing NumProperties *NumProperties Ind *Ind Justification *Justification Shade *Shade Kern *Kern Style *Style TextAlignment *TextAlignment AdjustRightInd *AdjustRightInd SnapToGrid *SnapToGrid Kinsoku *Kinsoku OverflowPunct *OverflowPunct RunProperties *RunProperties }
ParagraphProperties <w:pPr>
func (*ParagraphProperties) UnmarshalXML ¶
func (p *ParagraphProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type ParagraphSplitRule ¶
ParagraphSplitRule check whether the paragraph is a separator or not
func SplitDocxByPlainTextRegex ¶
func SplitDocxByPlainTextRegex(re *regexp.Regexp) ParagraphSplitRule
SplitDocxByPlainTextRegex matches p.String()
type PgMar ¶
type PgMar struct { Top int `xml:"w:top,attr"` Left int `xml:"w:left,attr"` Bottom int `xml:"w:bottom,attr"` Right int `xml:"w:right,attr"` Header int `xml:"w:header,attr"` Gutter int `xml:"w:gutter,attr"` }
PgMar show the page margin
func (*PgMar) UnmarshalXML ¶
UnmarshalXML ...
type PgSz ¶
type PgSz struct { W int `xml:"w:w,attr"` // width of paper H int `xml:"w:h,attr"` // high of paper }
PgSz show the paper size
func (*PgSz) UnmarshalXML ¶
UnmarshalXML ...
type PicCNvPicPr ¶
PicCNvPicPr represents the non-visual properties of a picture.
func (*PicCNvPicPr) UnmarshalXML ¶
func (p *PicCNvPicPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type Picture ¶
type Picture struct { XMLName xml.Name `xml:"pic:pic,omitempty"` XMLPIC string `xml:"xmlns:pic,attr,omitempty"` NonVisualPicProperties *PICNonVisualPicProperties BlipFill *PICBlipFill SpPr *PICSpPr }
Picture represents a picture in a Word document.
func (*Picture) UnmarshalXML ¶
UnmarshalXML ...
type Relationship ¶
type Relationship struct { ID string `xml:"Id,attr"` Type string `xml:"Type,attr"` Target string `xml:"Target,attr"` TargetMode string `xml:"TargetMode,attr,omitempty"` }
Relationship ...
type Relationships ¶
type Relationships struct { Xmlns string `xml:"xmlns,attr"` Relationship []Relationship }
Relationships ...
type Run ¶
type Run struct { XMLName xml.Name `xml:"w:r,omitempty"` Space string `xml:"xml:space,attr,omitempty"` RunProperties *RunProperties `xml:"w:rPr,omitempty"` InstrText string `xml:"w:instrText,omitempty"` Children []interface{} // contains filtered or unexported fields }
Run is part of a paragraph that has its own style. It could be a piece of text in bold, or a link
func (*Run) KeepElements ¶
KeepElements keep named elems amd removes others
names: *docx.Text *docx.Drawing *docx.Tab *docx.BarterRabbet
func (*Run) Underline ¶
Underline has several possible values including
none: Specifies that no underline should be applied. single: Specifies a single underline. words: Specifies that only words within the text should be underlined. double: Specifies a double underline. thick: Specifies a thick underline. dotted: Specifies a dotted underline. dash: Specifies a dash underline. dotDash: Specifies an alternating dot-dash underline. dotDotDash: Specifies an alternating dot-dot-dash underline. wave: Specifies a wavy underline. dashLong: Specifies a long dash underline. wavyDouble: Specifies a double wavy underline.
func (*Run) UnmarshalXML ¶
UnmarshalXML ...
type RunFonts ¶
type RunFonts struct { XMLName xml.Name `xml:"w:rFonts,omitempty"` ASCII string `xml:"w:ascii,attr,omitempty"` EastAsia string `xml:"w:eastAsia,attr,omitempty"` HAnsi string `xml:"w:hAnsi,attr,omitempty"` Hint string `xml:"w:hint,attr,omitempty"` }
RunFonts specifies the fonts used in the text of a run.
func (*RunFonts) UnmarshalXML ¶
UnmarshalXML ...
type RunMergeRule ¶
RunMergeRule compares two runs and decides whether they can be merged
func MergeSamePropRunsOf ¶
func MergeSamePropRunsOf(name ...string) RunMergeRule
MergeSamePropRunsOf merges runs with the same properties of names
type RunProperties ¶
type RunProperties struct { XMLName xml.Name `xml:"w:rPr,omitempty"` Fonts *RunFonts Bold *Bold ICs *struct{} `xml:"w:iCs,omitempty"` Italic *Italic Highlight *Highlight Color *Color Size *Size SizeCs *SizeCs Spacing *Spacing RunStyle *RunStyle Style *Style Shade *Shade Kern *Kern Underline *Underline VertAlign *VertAlign Strike *Strike }
RunProperties encapsulates visual properties of a run
func (*RunProperties) UnmarshalXML ¶
func (r *RunProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type SectPr ¶
type SectPr struct { XMLName xml.Name `xml:"w:sectPr,omitempty"` // properties of the document, including paper size PgSz *PgSz `xml:"w:pgSz,omitempty"` PgMar *PgMar `xml:"w:pgMar,omitempty"` Cols *Cols `xml:"w:cols,omitempty"` DocGrid *DocGrid `xml:"w:docGrid,omitempty"` }
SectPr show the properties of the document, like paper size
func (*SectPr) UnmarshalXML ¶
UnmarshalXML ...
type Shade ¶
type Shade struct { XMLName xml.Name `xml:"w:shd,omitempty"` Val string `xml:"w:val,attr,omitempty"` Color string `xml:"w:color,attr,omitempty"` Fill string `xml:"w:fill,attr,omitempty"` ThemeFill string `xml:"w:themeFill,attr,omitempty"` ThemeFillTint string `xml:"w:themeFillTint,attr,omitempty"` }
Shade is an element that represents a shading pattern applied to a document element.
func (*Shade) UnmarshalXML ¶
UnmarshalXML ...
type ShapeProperties ¶
type ShapeProperties struct { BWMode string `xml:"bwMode,attr"` Xfrm AXfrm PrstGeom APrstGeom SolidFill *ASolidFill BlipFill *ABlipFill NoFill *struct{} `xml:"a:noFill,omitempty"` Line *ALine }
ShapeProperties is a container element that represents the visual properties of a shape.
func (*ShapeProperties) UnmarshalXML ¶
func (w *ShapeProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type SnapToGrid ¶
type SnapToGrid struct { XMLName xml.Name `xml:"w:snapToGrid,omitempty"` Val int `xml:"w:val,attr"` }
SnapToGrid ...
type Spacing ¶
type Spacing struct { XMLName xml.Name `xml:"w:spacing,omitempty"` Val int `xml:"w:val,attr,omitempty"` BeforeLines int `xml:"w:beforeLines,attr,omitempty"` Before int `xml:"w:before,attr,omitempty"` Line int `xml:"w:line,attr,omitempty"` LineRule string `xml:"w:lineRule,attr,omitempty"` }
Spacing ...
func (*Spacing) UnmarshalXML ¶
UnmarshalXML ...
type Tab ¶
type Tab struct { XMLName xml.Name `xml:"w:tab,omitempty"` Val string `xml:"w:val,attr,omitempty"` Position int `xml:"w:pos,attr,omitempty"` }
Tab is the literal tab
func (*Tab) UnmarshalXML ¶
UnmarshalXML ...
type Table ¶
type Table struct { XMLName xml.Name `xml:"w:tbl,omitempty"` TableProperties *WTableProperties TableGrid *WTableGrid TableRows []*WTableRow // contains filtered or unexported fields }
Table represents a table within a Word document.
func (*Table) Justification ¶
Justification allows to set table's horizonal alignment
w:jc 属性的取值可以是以下之一: start:左对齐。 center:居中对齐。 end:右对齐。 both:两端对齐。 distribute:分散对齐。
func (*Table) UnmarshalXML ¶
UnmarshalXML implements the xml.Unmarshaler interface.
type Text ¶
type Text struct { XMLName xml.Name `xml:"w:t,omitempty"` XMLSpace string `xml:"xml:space,attr,omitempty"` Text string `xml:",chardata"` }
Text object contains the actual text
func (*Text) UnmarshalXML ¶
UnmarshalXML ...
type TextAlignment ¶
type TextAlignment struct { XMLName xml.Name `xml:"w:textAlignment,omitempty"` Val string `xml:"w:val,attr"` }
TextAlignment ...
type Underline ¶
type Underline struct { XMLName xml.Name `xml:"w:u,omitempty"` Val string `xml:"w:val,attr,omitempty"` }
Underline ...
type VertAlign ¶
type VertAlign struct { XMLName xml.Name `xml:"w:vertAlign,omitempty"` Val string `xml:"w:val,attr"` }
VertAlign ...
type WGridCol ¶
WGridCol is a structure that represents a table grid column of a Word document.
func (*WGridCol) UnmarshalXML ¶
UnmarshalXML ...
type WPAnchor ¶
type WPAnchor struct { XMLName xml.Name `xml:"wp:anchor,omitempty"` DistT int64 `xml:"distT,attr"` DistB int64 `xml:"distB,attr"` DistL int64 `xml:"distL,attr"` DistR int64 `xml:"distR,attr"` SimplePos int `xml:"simplePos,attr"` RelativeHeight int `xml:"relativeHeight,attr"` BehindDoc int `xml:"behindDoc,attr"` Locked int `xml:"locked,attr"` LayoutInCell int `xml:"layoutInCell,attr"` AllowOverlap int `xml:"allowOverlap,attr"` SimplePosXY *WPSimplePos PositionH *WPPositionH PositionV *WPPositionV Extent *WPExtent EffectExtent *WPEffectExtent WrapNone *struct{} `xml:"wp:wrapNone,omitempty"` WrapSquare *WPWrapSquare DocPr *WPDocPr CNvGraphicFramePr *WPCNvGraphicFramePr Graphic *AGraphic // contains filtered or unexported fields }
WPAnchor is an element that represents an anchored object in a Word document.
It allows for the positioning of a drawing object relative to a specific location in the text of the document. The <wp:anchor> element contains child elements that specify the dimensions and position of the anchored object, as well as the non-visual properties of the object. The <wp:anchor> element can contain the <wp:docPr> element, which contains the non-visual properties of the anchored object, such as its ID and name, as well as the <a:graphic> element, which specifies the visual properties of the object, such as its shape and fill.
func (*WPAnchor) UnmarshalXML ¶
UnmarshalXML ...
type WPCBackground ¶
type WPCBackground struct { XMLName xml.Name `xml:"wpc:bg,omitempty"` NoFill *struct{} `xml:"a:noFill,omitempty"` }
WPCBackground ...
func (*WPCBackground) UnmarshalXML ¶
func (b *WPCBackground) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) (err error)
UnmarshalXML ...
type WPCNvGraphicFramePr ¶
type WPCNvGraphicFramePr struct { XMLName xml.Name `xml:"wp:cNvGraphicFramePr,omitempty"` Locks AGraphicFrameLocks }
WPCNvGraphicFramePr represents the non-visual properties of a graphic frame.
func (*WPCNvGraphicFramePr) UnmarshalXML ¶
func (w *WPCNvGraphicFramePr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WPDocPr ¶
type WPDocPr struct { XMLName xml.Name `xml:"wp:docPr,omitempty"` ID int `xml:"id,attr"` Name string `xml:"name,attr,omitempty"` }
WPDocPr represents the document properties of a drawing in a Word document.
func (*WPDocPr) UnmarshalXML ¶
UnmarshalXML ...
type WPEffectExtent ¶
type WPEffectExtent struct { XMLName xml.Name `xml:"wp:effectExtent,omitempty"` L int64 `xml:"l,attr"` T int64 `xml:"t,attr"` R int64 `xml:"r,attr"` B int64 `xml:"b,attr"` }
WPEffectExtent represents the effect extent of a drawing in a Word document.
func (*WPEffectExtent) UnmarshalXML ¶
func (r *WPEffectExtent) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type WPExtent ¶
type WPExtent struct { XMLName xml.Name `xml:"wp:extent,omitempty"` CX int64 `xml:"cx,attr"` CY int64 `xml:"cy,attr"` }
WPExtent represents the extent of a drawing in a Word document.
CX CY 's unit is English Metric Units, which is 1/914400 inch
func (*WPExtent) UnmarshalXML ¶
UnmarshalXML ...
type WPGGroupShape ¶
type WPGGroupShape struct { XMLName xml.Name `xml:"wpg:grpSp,omitempty"` CNvPr *NonVisualProperties `xml:"wpg:cNvPr,omitempty"` CNvGrpSpPr *WPGcNvGrpSpPr GroupShapeProperties *ShapeProperties `xml:"wpg:grpSpPr,omitempty"` Elems []interface{} // contains filtered or unexported fields }
WPGGroupShape ...
func (*WPGGroupShape) UnmarshalXML ¶
func (w *WPGGroupShape) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WPGcNvGrpSpPr ¶
type WPGcNvGrpSpPr struct { XMLName xml.Name `xml:"wpg:cNvGrpSpPr,omitempty"` Locks *AGroupShapeLocks }
WPGcNvGrpSpPr represents the non-visual properties of a group shape.
func (*WPGcNvGrpSpPr) UnmarshalXML ¶
func (w *WPGcNvGrpSpPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WPInline ¶
type WPInline struct { XMLName xml.Name `xml:"wp:inline,omitempty"` DistT int64 `xml:"distT,attr"` DistB int64 `xml:"distB,attr"` DistL int64 `xml:"distL,attr"` DistR int64 `xml:"distR,attr"` Extent *WPExtent EffectExtent *WPEffectExtent DocPr *WPDocPr CNvGraphicFramePr *WPCNvGraphicFramePr Graphic *AGraphic // contains filtered or unexported fields }
WPInline is an element that represents an inline image within a text paragraph.
It contains information about the image's size and position, as well as any non-visual properties associated with the image. The <wp:inline> element can contain child elements such as <wp:extent> to specify the dimensions of the image and <wp:cNvGraphicFramePr> to specify the non-visual properties of the image. Inline images are often used in documents where the images are meant to be treated as part of the text flow, such as in a newsletter or a product brochure.
func (*WPInline) UnmarshalXML ¶
UnmarshalXML ...
type WPPositionH ¶
type WPPositionH struct { XMLName xml.Name `xml:"wp:positionH,omitempty"` RelativeFrom string `xml:"relativeFrom,attr"` PosOffset int64 `xml:"wp:posOffset"` }
WPPositionH represents the horizontal position of an object in a Word document.
func (*WPPositionH) UnmarshalXML ¶
func (r *WPPositionH) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type WPPositionV ¶
type WPPositionV struct { XMLName xml.Name `xml:"wp:positionV,omitempty"` RelativeFrom string `xml:"relativeFrom,attr"` PosOffset int64 `xml:"wp:posOffset"` }
WPPositionV represents the vertical position of an object in a Word document.
func (*WPPositionV) UnmarshalXML ¶
func (r *WPPositionV) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type WPSBodyPr ¶
type WPSBodyPr struct { XMLName xml.Name `xml:"wps:bodyPr,omitempty"` Rot int `xml:"rot,attr"` Vert string `xml:"vert,attr,omitempty"` Wrap string `xml:"wrap,attr,omitempty"` LIns int64 `xml:"lIns,attr"` TIns int64 `xml:"tIns,attr"` RIns int64 `xml:"rIns,attr"` BIns int64 `xml:"bIns,attr"` Anchor string `xml:"anchor,attr,omitempty"` AnchorCtr int `xml:"anchorCtr,attr"` Upright int `xml:"upright,attr"` NoAutofit *struct{} `xml:"a:noAutofit,omitempty"` }
WPSBodyPr represents the body properties for a WordprocessingML DrawingML shape.
func (*WPSBodyPr) UnmarshalXML ¶
UnmarshalXML ...
type WPSCNvCnPr ¶
type WPSCNvCnPr struct { XMLName xml.Name `xml:"wps:cNvCnPr,omitempty"` ConnShapeLocks *struct{} `xml:"a:cxnSpLocks,omitempty"` }
WPSCNvCnPr represents the non-visual drawing properties of a connector.
func (*WPSCNvCnPr) UnmarshalXML ¶
func (w *WPSCNvCnPr) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WPSCNvSpPr ¶
type WPSCNvSpPr struct { XMLName xml.Name `xml:"wps:cNvSpPr,omitempty"` TxBox int `xml:"txBox,attr,omitempty"` SPLocks *ASPLocks }
WPSCNvSpPr represents the non-visual properties of a WordArt object.
func (*WPSCNvSpPr) UnmarshalXML ¶
func (w *WPSCNvSpPr) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
UnmarshalXML ...
type WPSTextBox ¶
type WPSTextBox struct { XMLName xml.Name `xml:"wps:txbx,omitempty"` Content *WTextBoxContent // contains filtered or unexported fields }
WPSTextBox ...
func (*WPSTextBox) UnmarshalXML ¶
func (b *WPSTextBox) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WPSimplePos ¶
type WPSimplePos struct { XMLName xml.Name `xml:"wp:simplePos,omitempty"` X int64 `xml:"x,attr"` Y int64 `xml:"y,attr"` }
WPSimplePos represents the position of an object in a Word document.
type WPWrapSquare ¶
type WPWrapSquare struct { XMLName xml.Name `xml:"wp:wrapSquare,omitempty"` WrapText string `xml:"wrapText,attr"` }
WPWrapSquare represents the square wrapping of an object in a Word document.
type WTableBorder ¶
type WTableBorder struct { Val string `xml:"w:val,attr,omitempty"` Size int `xml:"w:sz,attr,omitempty"` Space int `xml:"w:space,attr,omitempty"` Color string `xml:"w:color,attr,omitempty"` }
WTableBorder is a structure representing a single border of a Word table.
func (*WTableBorder) UnmarshalXML ¶
func (t *WTableBorder) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type WTableBorders ¶
type WTableBorders struct { Top *WTableBorder `xml:"w:top,omitempty"` Left *WTableBorder `xml:"w:left,omitempty"` Bottom *WTableBorder `xml:"w:bottom,omitempty"` Right *WTableBorder `xml:"w:right,omitempty"` InsideH *WTableBorder `xml:"w:insideH,omitempty"` InsideV *WTableBorder `xml:"w:insideV,omitempty"` }
WTableBorders is a structure representing the borders of a Word table.
func (*WTableBorders) UnmarshalXML ¶
func (w *WTableBorders) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WTableCell ¶
type WTableCell struct { XMLName xml.Name `xml:"w:tc,omitempty"` TableCellProperties *WTableCellProperties Paragraphs []*Paragraph `xml:"w:p,omitempty"` // contains filtered or unexported fields }
WTableCell represents a cell within a table.
func (*WTableCell) AddParagraph ¶
func (c *WTableCell) AddParagraph() *Paragraph
AddParagraph adds a new paragraph
func (*WTableCell) Shade ¶
func (c *WTableCell) Shade(val, color, fill string) *WTableCell
Shade allows to set cell's shade
func (*WTableCell) UnmarshalXML ¶
func (c *WTableCell) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WTableCellProperties ¶
type WTableCellProperties struct { XMLName xml.Name `xml:"w:tcPr,omitempty"` TableCellWidth *WTableCellWidth VMerge *WvMerge GridSpan *WGridSpan TableBorders *WTableBorders `xml:"w:tcBorders"` Shade *Shade VAlign *WVerticalAlignment }
WTableCellProperties represents the properties of a table cell.
func (*WTableCellProperties) UnmarshalXML ¶
func (r *WTableCellProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WTableCellWidth ¶
type WTableCellWidth struct { XMLName xml.Name `xml:"w:tcW,omitempty"` W int64 `xml:"w:w,attr"` Type string `xml:"w:type,attr"` }
WTableCellWidth represents the width of a table cell.
在w:tcW元素中,type属性可以有以下几种取值:
"auto":表示表格列宽度由文本或表格布局决定。 "dxa":表示表格列宽度使用磅为单位。
不同的取值对应着不同的宽度计量单位和宽度定义方式。
type WTableGrid ¶
type WTableGrid struct { XMLName xml.Name `xml:"w:tblGrid,omitempty"` GridCols []*WGridCol `xml:"w:gridCol,omitempty"` }
WTableGrid is a structure that represents the table grid of a Word document.
func (*WTableGrid) UnmarshalXML ¶
func (t *WTableGrid) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WTableLook ¶
type WTableLook struct { XMLName xml.Name `xml:"w:tblLook,omitempty"` Val string `xml:"w:val,attr"` FirstRow int `xml:"w:firstRow,attr"` LastRow int `xml:"w:lastRow,attr"` FirstCol int `xml:"w:firstColumn,attr"` LastCol int `xml:"w:lastColumn,attr"` NoHBand int `xml:"w:noHBand,attr"` NoVBand int `xml:"w:noVBand,attr"` }
WTableLook represents the look of a table in a Word document.
func (*WTableLook) UnmarshalXML ¶
func (t *WTableLook) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML ...
type WTablePositioningProperties ¶
type WTablePositioningProperties struct { XMLName xml.Name `xml:"w:tblpPr,omitempty"` LeftFromText int `xml:"w:leftFromText,attr,omitempty"` RightFromText int `xml:"w:rightFromText,attr,omitempty"` VertAnchor string `xml:"w:vertAnchor,attr,omitempty"` HorzAnchor string `xml:"w:horzAnchor,attr,omitempty"` TblpXSpec string `xml:"w:tblpXSpec,attr,omitempty"` TblpYSpec string `xml:"w:tblpYSpec,attr,omitempty"` TblpX int `xml:"w:tblpX,attr,omitempty"` TblpY int `xml:"w:tblpY,attr,omitempty"` }
WTablePositioningProperties is an element that contains the properties for positioning a table within a document page, including its horizontal and vertical anchors, distance from text, and coordinates.
func (*WTablePositioningProperties) UnmarshalXML ¶
func (tp *WTablePositioningProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
UnmarshalXML ...
type WTableProperties ¶
type WTableProperties struct { XMLName xml.Name `xml:"w:tblPr,omitempty"` Position *WTablePositioningProperties Style *WTableStyle Width *WTableWidth Justification *Justification `xml:"w:jc,omitempty"` TableBorders *WTableBorders `xml:"w:tblBorders"` Look *WTableLook }
WTableProperties is an element that represents the properties of a table in Word document.
func (*WTableProperties) UnmarshalXML ¶
func (t *WTableProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML implements the xml.Unmarshaler interface.
type WTableRow ¶
type WTableRow struct { XMLName xml.Name `xml:"w:tr,omitempty"` // RsidR string `xml:"w:rsidR,attr,omitempty"` // RsidRPr string `xml:"w:rsidRPr,attr,omitempty"` // RsidTr string `xml:"w:rsidTr,attr,omitempty"` TableRowProperties *WTableRowProperties TableCells []*WTableCell // contains filtered or unexported fields }
WTableRow represents a row within a table.
func (*WTableRow) Justification ¶
Justification allows to set table's horizonal alignment
w:jc 属性的取值可以是以下之一: start:左对齐。 center:居中对齐。 end:右对齐。 both:两端对齐。 distribute:分散对齐。
func (*WTableRow) UnmarshalXML ¶
UnmarshalXML ...
type WTableRowHeight ¶
type WTableRowHeight struct { XMLName xml.Name `xml:"w:trHeight,omitempty"` Rule string `xml:"w:hRule,attr,omitempty"` Val int64 `xml:"w:val,attr"` }
WTableRowHeight represents the height of a row within a table.
type WTableRowProperties ¶
type WTableRowProperties struct { XMLName xml.Name `xml:"w:trPr,omitempty"` TableRowHeight *WTableRowHeight Justification *Justification }
WTableRowProperties represents the properties of a row within a table.
func (*WTableRowProperties) UnmarshalXML ¶
func (t *WTableRowProperties) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WTableStyle ¶
type WTableStyle struct { XMLName xml.Name `xml:"w:tblStyle,omitempty"` Val string `xml:"w:val,attr"` }
WTableStyle represents the style of a table in a Word document.
func (*WTableStyle) UnmarshalXML ¶
func (t *WTableStyle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
UnmarshalXML ...
type WTableWidth ¶
type WTableWidth struct { XMLName xml.Name `xml:"w:tblW,omitempty"` W int64 `xml:"w:w,attr"` Type string `xml:"w:type,attr"` }
WTableWidth represents the width of a table in a Word document.
func (*WTableWidth) UnmarshalXML ¶
func (t *WTableWidth) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
UnmarshalXML ...
type WTextBoxContent ¶
type WTextBoxContent struct { XMLName xml.Name `xml:"w:txbxContent,omitempty"` Paragraphs []Paragraph `xml:"w:p,omitempty"` // contains filtered or unexported fields }
WTextBoxContent ...
func (*WTextBoxContent) UnmarshalXML ¶
func (c *WTextBoxContent) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WVerticalAlignment ¶
type WVerticalAlignment struct { XMLName xml.Name `xml:"w:vAlign,omitempty"` Val string `xml:"w:val,attr"` }
WVerticalAlignment represents the vertical alignment of the content of a cell.
type WordprocessingCanvas ¶
type WordprocessingCanvas struct { XMLName xml.Name `xml:"wpc:wpc,omitempty"` Background *WPCBackground Whole *WPCWhole Items []interface{} // contains filtered or unexported fields }
WordprocessingCanvas ...
func (*WordprocessingCanvas) UnmarshalXML ¶
func (c *WordprocessingCanvas) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) (err error)
UnmarshalXML ...
type WordprocessingGroup ¶
type WordprocessingGroup struct { XMLName xml.Name `xml:"wpg:wgp,omitempty"` CNvGrpSpPr *WPGcNvGrpSpPr GroupShapeProperties *ShapeProperties `xml:"wpg:grpSpPr,omitempty"` Elems []interface{} // contains filtered or unexported fields }
WordprocessingGroup represents a group of drawing objects or pictures
func (*WordprocessingGroup) UnmarshalXML ¶
func (w *WordprocessingGroup) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WordprocessingShape ¶
type WordprocessingShape struct { XMLName xml.Name `xml:"wps:wsp,omitempty"` CNvPr *NonVisualProperties `xml:"wps:cNvPr,omitempty"` CNvCnPr *WPSCNvCnPr CNvSpPr *WPSCNvSpPr SpPr *ShapeProperties `xml:"wps:spPr,omitempty"` TextBox *WPSTextBox BodyPr *WPSBodyPr // contains filtered or unexported fields }
WordprocessingShape is a container for a WordprocessingML DrawingML shape.
func (*WordprocessingShape) UnmarshalXML ¶
func (w *WordprocessingShape) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
UnmarshalXML ...
type WvMerge ¶
type WvMerge struct { XMLName xml.Name `xml:"w:vMerge,omitempty"` Val string `xml:"w:val,attr,omitempty"` }
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 <w:vMerge> 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 <w:vMerge> 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.
Source Files
¶
- apidrawing.go
- apilink.go
- apipara.go
- apirel.go
- apirun.go
- apishape.go
- apitable.go
- apitext.go
- docx.go
- empty.go
- fs.go
- helper.go
- id.go
- image.go
- link.go
- media.go
- pack.go
- slice.go
- structcanvas.go
- structdoc.go
- structdrawing.go
- structeffects.go
- structgroup.go
- structlink.go
- structnum.go
- structpara.go
- structrel.go
- structrun.go
- structsect.go
- structshape.go
- structtable.go
- structtext.go
- theme.go
- unpack.go