docx

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Items  []DocItem
	Params BodyParams `xml:"sectPr"`
}

Body - тело документа

type BodyParams

type BodyParams struct {
	HeaderReference *ReferenceValue `xml:"headerReference,omitempty"`
	FooterReference *ReferenceValue `xml:"footerReference,omitempty"`
	PageSize        SizeValue       `xml:"pgSz"`
	PageMargin      MarginValue     `xml:"pgMar"`
	Bidi            IntValue        `xml:"bidi"`
}

BodyParams - параметры тела документа

type BoolValue

type BoolValue struct {
	Value bool `xml:"val,attr"`
}

BoolValue - одиночное bool значение

type ColSpaceValue added in v0.2.1

type ColSpaceValue struct {
	Space string `xml:"space,attr"`
}

type DocGridValue added in v0.2.1

type DocGridValue struct {
	LinePitch string `xml:"linePitch,attr"`
}

type DocItem

type DocItem interface {
	SetAttrs(attrs []xml.Attr)
	Tag() string
	Type() DocItemType
	PlainText() string
	Clone() DocItem
	// contains filtered or unexported methods
}

DocItem - интерфейс элемента документа

type DocItemType

type DocItemType int

DocItemType - тип элемента

const (
	Paragraph DocItemType = iota
	Record
	Table
)

Paragraph - параграф

type Document

type Document struct {
	Scheme     map[string]string
	SkipScheme string
	Body       Body `xml:"body"`
}

Document - документ разметки DOCX

func (*Document) Decode

func (doc *Document) Decode(reader io.Reader) error

Decode (Document) - декодирование документа

func (*Document) Encode

func (doc *Document) Encode(writer io.Writer) error

Encode - кодирование

type EmptyValue

type EmptyValue struct {
}

EmptyValue - пустое значение

type FloatValue

type FloatValue struct {
	Value float64 `xml:"val,attr"`
}

FloatValue - одиночное float значение

type Header struct {
	Scheme     map[string]string
	SkipScheme string
	Items      []DocItem
}

Header - разметка заголовка DOCX

func (*Header) Decode

func (h *Header) Decode(reader io.Reader) error

Decode (Document) - декодирование документа

func (*Header) Encode

func (h *Header) Encode(writer io.Writer) error

Encode - кодирование

type HeightValue

type HeightValue struct {
	Value      int64  `xml:"val,attr"`
	HeightRule string `xml:"hRule,attr,omitempty"`
}

HeightValue - значение высоты

func (*HeightValue) From

func (h *HeightValue) From(h1 *HeightValue)

From (HeightValue)

type IntValue

type IntValue struct {
	Value int64 `xml:"val,attr"`
}

IntValue - одиночное int значение

func (*IntValue) From

func (i *IntValue) From(i1 *IntValue)

From (IntValue)

type MarginValue

type MarginValue struct {
	Top    int64 `xml:"top,attr"`
	Left   int64 `xml:"left,attr"`
	Bottom int64 `xml:"bottom,attr"`
	Right  int64 `xml:"right,attr"`
	Header int64 `xml:"header,attr,omitempty"`
	Footer int64 `xml:"footer,attr,omitempty"`
}

MarginValue - margin значение

func (*MarginValue) From

func (m *MarginValue) From(m1 *MarginValue)

From (MarginValue)

type Margins

type Margins struct {
	Top    WidthValue `xml:"top"`
	Left   WidthValue `xml:"left"`
	Bottom WidthValue `xml:"bottom"`
	Right  WidthValue `xml:"right"`
}

Margins - margins значение

func (*Margins) From

func (m *Margins) From(m1 *Margins)

From (Margins)

type ParagraphInd added in v0.2.1

type ParagraphInd struct {
	Left      string `xml:"left,attr"`
	Right     string `xml:"right,attr"`
	Hanging   string `xml:"hanging,attr"`
	FirstLine string `xml:"firstLine,attr"`
}

ParagraphInd = <w:ind w:left="2136" w:right="1209" w:hanging="882" w:firstLine="223"/>

type ParagraphItem

type ParagraphItem struct {
	Params ParagraphParams `xml:"pPr"`
	Items  []DocItem
	Attrs  []xml.Attr
}

ParagraphItem - параграф

func (*ParagraphItem) Clone

func (item *ParagraphItem) Clone() DocItem

Clone - клонирование

func (*ParagraphItem) PlainText

func (item *ParagraphItem) PlainText() string

PlainText - текст

func (*ParagraphItem) SetAttrs added in v0.2.1

func (item *ParagraphItem) SetAttrs(attrs []xml.Attr)

func (*ParagraphItem) Tag

func (item *ParagraphItem) Tag() string

Tag - имя тега элемента

func (*ParagraphItem) Type

func (item *ParagraphItem) Type() DocItemType

Type - тип элемента

type ParagraphParams

type ParagraphParams struct {
	Style                 *StringValue   `xml:"pStyle,omitempty"`
	Tabs                  *ParagraphTabs `xml:"tabs,omitempty"`
	Spacing               *SpacingValue  `xml:"spacing,omitempty"`
	Jc                    *StringValue   `xml:"jc,omitempty"`
	Bidi                  *IntValue      `xml:"bidi,omitempty"`
	Size                  *StringValue   `xml:"sz"`
	ParagraphRecordParams *RecordParams  `xml:"rPr"`
	Ind                   *ParagraphInd  `xml:"ind"`
	Section               *SectionParam  `xml:"sectPr,omitempty"`
}

ParagraphParams - параметры параграфа

type ParagraphTab added in v0.2.1

type ParagraphTab struct {
	Value    string `xml:"val,attr"`
	Position string `xml:"pos,attr"`
}

type ParagraphTabs added in v0.2.1

type ParagraphTabs struct {
	Tab []*ParagraphTab `xml:"tab"`
}

type RecordFonts

type RecordFonts struct {
	ASCII      string `xml:"ascii,attr"`
	CS         string `xml:"cs,attr"`
	HandleANSI string `xml:"hAnsi,attr"`
	EastAsia   string `xml:"eastAsia,attr"`
	HandleInt  string `xml:"hint,attr,omitempty"`
}

RecordFonts - fonts in record

type RecordItem

type RecordItem struct {
	PageBreak bool `xml:"lastRenderedPageBreak,omitempty"`
	Attrs     []xml.Attr
	Params    RecordParams `xml:"rPr,omitempty"`
	Text      string       `xml:"t,omitempty"`
	Tab       bool         `xml:"tab,omitempty"`
	Break     bool         `xml:"br,omitempty"`
}

RecordItem - record item

func (*RecordItem) Clone

func (item *RecordItem) Clone() DocItem

Clone - клонирование

func (*RecordItem) PlainText

func (item *RecordItem) PlainText() string

PlainText - текст

func (*RecordItem) SetAttrs added in v0.2.1

func (item *RecordItem) SetAttrs(attrs []xml.Attr)

func (*RecordItem) Tag

func (item *RecordItem) Tag() string

Tag - имя тега элемента

func (*RecordItem) Type

func (item *RecordItem) Type() DocItemType

Type - тип элемента

type RecordParamSize added in v0.2.1

type RecordParamSize struct {
	Value string `xml:"val,attr"`
}

type RecordParams

type RecordParams struct {
	Fonts     *RecordFonts     `xml:"rFonts,omitempty"`
	Rtl       *IntValue        `xml:"rtl,omitempty"`
	Size      *RecordParamSize `xml:"sz,omitempty"`
	SizeCs    *IntValue        `xml:"szCs,omitempty"`
	Lang      *StringValue     `xml:"lang,omitempty"`
	Underline *StringValue     `xml:"u,omitempty"`
	Italic    *EmptyValue      `xml:"i,omitempty"`
	Bold      *EmptyValue      `xml:"b,omitempty"`
	BoldCS    *EmptyValue      `xml:"bCs,omitempty"`
	Color     *StringValue     `xml:"color,omitempty"`
}

RecordParams - params record

type ReferenceValue

type ReferenceValue struct {
	Type string `xml:"type,attr"`
	ID   string `xml:"id,attr"`
}

ReferenceValue - reference value

type SectionParam added in v0.2.1

type SectionParam struct {
	HeaderReference *ReferenceValue `xml:"headerReference,omitempty"`
	FooterReference *ReferenceValue `xml:"footerReference,omitempty"`
	Type            *StringValue    `xml:"type,omitempty"`
	PageSize        *SizeValue      `xml:"pgSz,omitempty"`
	PageMargin      *MarginValue    `xml:"pgMar,omitempty"`
	Columns         *ColSpaceValue  `xml:"cols,omitempty"`
	DocumentGrid    *DocGridValue   `xml:"docGrid,omitempty"`
}

type ShadowValue

type ShadowValue struct {
	Value string `xml:"val,attr"`
	Color string `xml:"color,attr"`
	Fill  string `xml:"fill,attr"`
}

ShadowValue - значение тени

func (*ShadowValue) From

func (s *ShadowValue) From(s1 *ShadowValue)

From (ShadowValue)

type SimpleDocxFile

type SimpleDocxFile struct {
	// contains filtered or unexported fields
}

SimpleDocxFile - файл docx

func OpenFile

func OpenFile(fileName string) (*SimpleDocxFile, error)

OpenFile - Открытие файла DOCX

func (*SimpleDocxFile) Render

func (f *SimpleDocxFile) Render(v interface{}) error

Render (SimpleDocxFile) - рендер шаблона

func (*SimpleDocxFile) RenderHeader

func (f *SimpleDocxFile) RenderHeader(index int, v interface{}) error

RenderHeader (SimpleDocxFile) - рендер заголовка шаблона

func (*SimpleDocxFile) Save

func (f *SimpleDocxFile) Save(fileName string) error

Save (SimpleDocxFile) - сохранить

func (*SimpleDocxFile) Write

func (f *SimpleDocxFile) Write(writer io.Writer) error

Write (SimpleDocxFile)

type SizeValue

type SizeValue struct {
	Width       int64  `xml:"w,attr"`
	Height      int64  `xml:"h,attr"`
	Orientation string `xml:"orient,attr,omitempty"`
}

SizeValue - значение размера

func (*SizeValue) From

func (s *SizeValue) From(s1 *SizeValue)

From (SizeValue)

type SpacingValue

type SpacingValue struct {
	After    string `xml:"after,attr"`
	Before   string `xml:"before,attr"`
	Line     string `xml:"line,attr"`
	LineRule string `xml:"lineRule,attr"`
}

SpacingValue - spacing value

func (*SpacingValue) From

func (s *SpacingValue) From(s1 *SpacingValue)

From (SpacingValue)

type StringValue

type StringValue struct {
	Value string `xml:"val,attr,omitempty"`
}

StringValue - одиночное string значение

func (*StringValue) From

func (s *StringValue) From(s1 *StringValue)

From (StringValue)

type TableBorder

type TableBorder struct {
	Value  string `xml:"val,attr"`
	Color  string `xml:"color,attr"`
	Size   int64  `xml:"sz,attr"`
	Space  int64  `xml:"space,attr"`
	Shadow int64  `xml:"shadow,attr"`
	Frame  int64  `xml:"frame,attr"`
}

TableBorder in borders

func (*TableBorder) From

func (b *TableBorder) From(b1 *TableBorder)

From (TableBorder)

type TableBorders

type TableBorders struct {
	Top     TableBorder  `xml:"top"`
	Left    TableBorder  `xml:"left"`
	Bottom  TableBorder  `xml:"bottom"`
	Right   TableBorder  `xml:"right"`
	InsideH *TableBorder `xml:"insideH,omitempty"`
	InsideV *TableBorder `xml:"insideV,omitempty"`
}

TableBorders in table

func (*TableBorders) From

func (b *TableBorders) From(b1 *TableBorders)

From (TableBorders)

type TableCell

type TableCell struct {
	Params TableCellParams `xml:"tcPr"`
	Items  []DocItem
}

TableCell - table cell

func (*TableCell) Clone

func (cell *TableCell) Clone() *TableCell

Clone (TableCell) - клонирование ячейки

type TableCellParams

type TableCellParams struct {
	Width         *WidthValue   `xml:"tcW,omitempty"`
	Borders       *TableBorders `xml:"tcBorders,omitempty"`
	Shadow        *ShadowValue  `xml:"shd,omitempty"`
	Margins       *Margins      `xml:"tcMar,omitempty"`
	VerticalAlign *StringValue  `xml:"vAlign,omitempty"`
	VerticalMerge *StringValue  `xml:"vMerge,omitempty"`
	GridSpan      *IntValue     `xml:"gridSpan,omitempty"`
	HideMark      *EmptyValue   `xml:"hideMark,omitempty"`
	NoWrap        *EmptyValue   `xml:"noWrap,omitempty"`
}

TableCellParams - cell params

type TableGrid

type TableGrid struct {
	Cols []*WidthValue `xml:"gridCol,omitempty"`
}

TableGrid - Grid table

type TableItem

type TableItem struct {
	Attrs  []xml.Attr
	Params TableParams `xml:"tblPr"`
	Grid   TableGrid   `xml:"tblGrid"`
	Rows   []*TableRow `xml:"tr,omitempty"`
}

TableItem - элемент таблици

func (*TableItem) Clone

func (item *TableItem) Clone() DocItem

Clone - клонирование

func (*TableItem) PlainText

func (item *TableItem) PlainText() string

PlainText - текст

func (*TableItem) SetAttrs added in v0.2.1

func (item *TableItem) SetAttrs(attrs []xml.Attr)

SetAttrs устанавливает переданные атрибуты элемента. Атрибуты передаются в виде среза xml.Attr Переданный срез атрибутов присваивается полю Attrs элемента TableItem. Example usage:

attrs := []xml.Attr{
    xml.Attr{Name: xml.Name{Local: "attr1"}, Value: "value1"},
    xml.Attr{Name: xml.Name{Local: "attr2"}, Value: "value2"},
}

item.SetAttrs(attrs)

func (*TableItem) Tag

func (item *TableItem) Tag() string

Tag - имя тега элемента

func (*TableItem) Type

func (item *TableItem) Type() DocItemType

Type - тип элемента

type TableLayout

type TableLayout struct {
	Type string `xml:"type,attr"`
}

TableLayout - layout params

type TableLook added in v0.2.1

type TableLook struct {
	Value       string `xml:"val,attr"`
	FirstRow    string `xml:"firstRow,attr"`
	LastRow     string `xml:"lastRow,attr"`
	FirstColumn string `xml:"firstColumn,attr"`
	LastColumn  string `xml:"lastColumn,attr"`
	NoHBand     string `xml:"noHBand,attr"`
	NoVBand     string `xml:"noVBand,attr"`
}

TableLook <w:tblLook w:val="01E0" w:firstRow="1" w:lastRow="1" w:firstColumn="1" w:lastColumn="1" w:noHBand="0" w:noVBand="0"/>

type TableParams

type TableParams struct {
	Width   *WidthValue   `xml:"tblW,omitempty"`
	Style   *StringValue  `xml:"tblStyle,omitempty"`
	Jc      *StringValue  `xml:"jc,omitempty"`
	Ind     *WidthValue   `xml:"tblInd,omitempty"`
	Borders *TableBorders `xml:"tblBorders,omitempty"`
	Shadow  *ShadowValue  `xml:"shd,omitempty"`
	Layout  *TableLayout  `xml:"tblLayout,omitempty"`
	DocGrid *IntValue     `xml:"docGrid,omitempty"`
	Look    *TableLook    `xml:"tblLook,omitempty"`
}

TableParams - Params table

type TableParamsEx

type TableParamsEx struct {
	Shadow ShadowValue `xml:"shd"`
}

TableParamsEx - Other params table

type TableRow

type TableRow struct {
	Attr        []xml.Attr
	OtherParams *TableParamsEx `xml:"tblPrEx,omitempty"`
	Params      TableRowParams `xml:"trPr"`
	Cells       []*TableCell   `xml:"tc,omitempty"`
}

TableRow - row in table

func (*TableRow) Clone

func (row *TableRow) Clone() *TableRow

Clone (TableRow) - клонирование строки таблицы

type TableRowParams

type TableRowParams struct {
	Height   HeightValue `xml:"trHeight"`
	IsHeader bool
}

TableRowParams - row params

type WidthValue

type WidthValue struct {
	Value int64  `xml:"w,attr"`
	Type  string `xml:"type,attr,omitempty"`
}

WidthValue - значение длины

func (*WidthValue) From

func (w *WidthValue) From(w1 *WidthValue)

From (WidthValue)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL