docx

package
v0.0.0-...-a51dd7f Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 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 DocItem

type DocItem interface {
	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 ParagraphItem

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

ParagraphItem - параграф

func (*ParagraphItem) Clone

func (item *ParagraphItem) Clone() DocItem

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

func (*ParagraphItem) PlainText

func (item *ParagraphItem) PlainText() string

PlainText - текст

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"`
	Spacing *SpacingValue `xml:"spacing,omitempty"`
	Jc      *StringValue  `xml:"jc,omitempty"`
	Bidi    *IntValue     `xml:"bidi,omitempty"`
}

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

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 {
	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) Tag

func (item *RecordItem) Tag() string

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

func (*RecordItem) Type

func (item *RecordItem) Type() DocItemType

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

type RecordParams

type RecordParams struct {
	Fonts     *RecordFonts `xml:"rFonts,omitempty"`
	Rtl       *IntValue    `xml:"rtl,omitempty"`
	Size      *IntValue    `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 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    int64  `xml:"after,attr"`
	Before   int64  `xml:"before,attr"`
	Line     int64  `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 {
	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) 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 TableParams

type TableParams struct {
	Width   *WidthValue   `xml:"tblW,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"`
}

TableParams - Params table

type TableParamsEx

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

TableParamsEx - Other params table

type TableRow

type TableRow struct {
	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