docx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeTypeMain   = ContentTypeType("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")
	ContentTypeTypeStyle  = ContentTypeType("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
	ContentTypeTypeCore   = ContentTypeType("application/vnd.openxmlformats-package.core-properties+xml")
	ContentTypeTypeApp    = ContentTypeType("application/vnd.openxmlformats-officedocument.extended-properties+xml")
	ContentTypeTypeHeader = ContentTypeType("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")
	ContentTypeTypeFooter = ContentTypeType("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")
)
View Source
const (
	DocumentContentTypeParagraph = DocumentContentType("paragraph")
	DocumentContentTypeTable     = DocumentContentType("table")
)
View Source
const (
	FooterTypeFirst   = FooterType("first")
	FooterTypeEven    = FooterType("even")
	FooterTypeDefault = FooterType("default")
)
View Source
const (
	HeaderTypeFirst   = HeaderType("first")
	HeaderTypeEven    = HeaderType("even")
	HeaderTypeDefault = HeaderType("default")
)
View Source
const (
	RelationshipTypeStyle     = RelationshipType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles")
	RelationshipTypeSetting   = RelationshipType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings")
	RelationshipTypeFontTable = RelationshipType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable")
	RelationshipTypeHeader    = RelationshipType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header")
	RelationshipTypeFooter    = RelationshipType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer")
)
View Source
const (
	StyleTypeParagraph = StyleType("paragraph")
	StyleTypeCharacter = StyleType("character")
	StyleTypeTable     = StyleType("table")
)
View Source
const DocumentDefaultHeight = 16838

DocumentDefaultHeight 文档默认高度

View Source
const DocumentDefaultWidth = 11906

DocumentDefaultWidth 文档默认宽度

View Source
const TableDefaultWidth = 8800

TableDefaultWidth 表格默认宽度

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// Template 模板名称
	Template string

	// Application 生产者应用的名称
	Application string

	// Security 加密级别
	Security int
}

App app.xml

func (*App) GetXmlBytes

func (a *App) GetXmlBytes() ([]byte, error)

type Background

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

themeTint 文档的背景配置

func (*Background) GetXmlBytes

func (b *Background) GetXmlBytes() ([]byte, error)

func (*Background) SetBackground

func (b *Background) SetBackground(color, themeColor, themeShade, themeTint string) *Background

SetBackground 设置文档背景

func (*Background) SetColor

func (b *Background) SetColor(color string) *Background

SetColor 设置颜色

func (*Background) SetThemeColor

func (b *Background) SetThemeColor(themeColor string) *Background

SetThemeColor 设置主题颜色

func (*Background) SetThemeShade

func (b *Background) SetThemeShade(themeShade string) *Background

SetThemeShade 设置主题阴影

func (*Background) SetThemeTint

func (b *Background) SetThemeTint(themeTint string) *Background

SetThemeTint 设置主题的色调值 0-255的16进制字符串

type ContentTypeType

type ContentTypeType string

type ContentTypes

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

ContentTypes [Content_Types].xml

func (*ContentTypes) AddContentType

func (c *ContentTypes) AddContentType(path string, ct ContentTypeType) *ContentTypes

func (*ContentTypes) GetXmlBytes

func (c *ContentTypes) GetXmlBytes() ([]byte, error)

type Core

type Core struct {
	// CreateUser 创建文档的用户名称
	CreateUser string

	// CreateTime 文档的创建时间
	CreateTime time.Time

	// LastModifyUser 最后修改的用户名
	LastModifyUser string

	// LastModifyTime 最后修改的时间
	LastModifyTime time.Time

	// Version 版本号,每修改一次+1
	Version int
}

Core core.xml

func (*Core) GetXmlBytes

func (c *Core) GetXmlBytes() ([]byte, error)

GetXmlBytes GetBody 获取core.xml文件的内容

type Document

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

Document 文档结构定义 该结构统一对.docx格式文档进行操作

func New

func New() (*Document, error)

New 新建一篇文档

func (*Document) AddParagraph

func (d *Document) AddParagraph() *paragraph.Paragraph

AddParagraph 添加一个段落

func (*Document) AddTable

func (d *Document) AddTable() *table.Table

AddTable 添加一个表格

func (*Document) AddTableWithColumns

func (d *Document) AddTableWithColumns(columns int) *table.Table

AddTableWithColumns 添加一个拥有指定列数量的表格

func (*Document) AddTableWithColumnsAndAutoWidth

func (d *Document) AddTableWithColumnsAndAutoWidth(columns int) *table.Table

AddTableWithColumnsAndAutoWidth 添加一个拥有指定列数量的表格,并且自动计算所有列的宽度

func (*Document) GetBackground

func (d *Document) GetBackground() *Background

GetBackground 获取背景配置结构指针

func (*Document) GetContents

func (d *Document) GetContents() []*DocumentContent

func (*Document) GetFooters

func (d *Document) GetFooters() []*footer.Footer

func (*Document) GetHeaders

func (d *Document) GetHeaders() []*header.Header

func (*Document) GetProperties

func (d *Document) GetProperties() *Styles

func (*Document) GetSection

func (d *Document) GetSection() *section.Section

GetSection 获取节属性配置结构指针

func (*Document) NewFooter

func (d *Document) NewFooter() *footer.Footer

NewFooter 新建一个页脚

func (*Document) NewHeader

func (d *Document) NewHeader() *header.Header

NewHeader 新建一个页头

func (*Document) Save

func (d *Document) Save(path string) error

Save 保存文件到路径 path 为一个完整的包含文件后缀名的路径地址

func (*Document) SetDocumentUser

func (d *Document) SetDocumentUser(username string) *Document

SetDocumentUser 设置文档的创建与修改用户

func (*Document) UseFooter

func (d *Document) UseFooter(footerType FooterType, ftr *footer.Footer) *Document

UseFooter 使用指定的页脚

func (*Document) UseHeader

func (d *Document) UseHeader(headerType HeaderType, hdr *header.Header) *Document

UseHeader 使用指定的页头

type DocumentContent

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

DocumentContent 文档内容

type DocumentContentType

type DocumentContentType string

type FooterType

type FooterType string

type HeaderType

type HeaderType string

type Relationship

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

Relationship 关联定义

type RelationshipType

type RelationshipType string

type Relationships

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

Relationships 文档关联定义

func (*Relationships) AddRelationship

func (r *Relationships) AddRelationship(target string, relationshipType RelationshipType) string

AddRelationship 添加一个关联定义

func (*Relationships) GetXmlBytes

func (r *Relationships) GetXmlBytes() ([]byte, error)

type Style

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

Style 样式结构

func (*Style) GetXmlBytes

func (s *Style) GetXmlBytes() ([]byte, error)

func (*Style) SetPPr

func (s *Style) SetPPr(pPr *paragraph.PPr) *Style

SetPPr 设置段落样式

func (*Style) SetRPr

func (s *Style) SetRPr(rPr *run.RPr) *Style

SetRPr 设置文本样式

func (*Style) SetStyleId

func (s *Style) SetStyleId(styleId string) *Style

SetStyleId 设置样式ID

func (*Style) SetStyleType

func (s *Style) SetStyleType(styleType StyleType) *Style

SetStyleType 设置样式类型

func (*Style) SetTblPr

func (s *Style) SetTblPr(tblPr *table.TblPr) *Style

SetTblPr 设置表格样式

type StyleType

type StyleType string

type Styles

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

Styles 样式配置结构

func (*Styles) GetDefaultParagraphProperties

func (s *Styles) GetDefaultParagraphProperties() *paragraph.PPr

func (*Styles) GetDefaultRunProperties

func (s *Styles) GetDefaultRunProperties() *run.RPr

func (*Styles) GetXmlBytes

func (s *Styles) GetXmlBytes() ([]byte, error)

Directories

Path Synopsis
row

Jump to

Keyboard shortcuts

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