Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyTemplateToXml(f *zip.File, templateValues any, templateFuncs template.FuncMap) ([]byte, error)
- func ExtractChartFilename(path string) (string, error)
- func ParseContentTypes(data []byte) (*contentTypes, error)
- func ParseDocumentMeta(zm goziputils.ZipMap, tf template.FuncMap) (*documentMeta, error)
- func PatchXml(srcXml string) string
- func UpdateChart(fileContent []byte, cellAndValues map[string]string) ([]byte, error)
- type Media
- type MediaMap
- type MediaRel
- type Relationship
- type XmlImageData
Constants ¶
View Source
const ( DOCX_NEWLINE_INJECT = `</w:t><w:br/><w:t>` DOCX_BREAKPARAGRAPH_INJECT = `</w:t></w:r></w:p><w:p><w:r><w:t>` STYLE_WRAPPER_F = `<w:rPr>%s</w:rPr><w:t>%s</w:t>` BOLD_W_TAG = `<w:b /><w:bCs />` ITALIC_W_TAG = `<w:i /><w:iCs />` UNDERLINE_W_TAG = `<w:u w:val="single"/>` STRIKETHROUGH_W_TAG = `<w:strike />` FONT_SIZE_W_TAGS_F = `<w:sz w:val="%d" /><w:szCs w:val="%d" />` COLOR_W_TAG_F = `<w:color w:val="%s" />` HIGHLIGHT_W_TAG_F = `<w:highlight w:val="%s" />` // HIGHLIGHT all values: https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.highlightcolor?view=openxml-2.8.1 SHADING_W_TAG_F = `<w:shd w:val="clear" w:color="auto" w:fill="%s"/>` )
View Source
const ( FONT_SIZE_STYLE_PREFIX = "fontSize:" FONT_SIZE_STYLE_PREFIX_SHORT = "fs:" TEXT_SHADING_STYLE_PREFIX = "bg:" )
View Source
const DOC_PR_ID_ROOF = 2_147_483_647 // docx id attributes are 32-bit signed integers
View Source
const (
ImageMediaType = iota + 1
)
Variables ¶
View Source
var ( BOLD_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, BOLD_W_TAG, "%s") ITALIC_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, ITALIC_W_TAG, "%s") UNDERLINE_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, UNDERLINE_W_TAG, "%s") STRIKETHROUGH_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, STRIKETHROUGH_W_TAG, "%s") COLOR_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, COLOR_W_TAG_F, "%s") HIGHLIGHT_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, HIGHLIGHT_W_TAG_F, "%s") SHADING_WRAPPER_F = fmt.Sprintf(STYLE_WRAPPER_F, SHADING_W_TAG_F, "%s") )
View Source
var TemplateFuncs = template.FuncMap{
"list": list,
"bold": bold,
"italic": italic,
"underline": underline,
"strike": strike,
"fontSize": fontSize,
"inlineStyledText": inlineStyledText,
"styledText": styledText,
"color": color,
"highlight": highlight,
"preserveNewline": preserveNewline,
"breakParagraph": breakParagraph,
"shadeTextBg": shadeTextBg,
"image": image,
"replaceImage": replaceImage,
"shapeBgFillColor": shapeBgFillColor,
"tableCellBgColor": tableCellBgColor,
}
Functions ¶
func ApplyTemplateToXml ¶
func ExtractChartFilename ¶
ExtractChartFilename now only works with a single submatch
func ParseContentTypes ¶
func ParseDocumentMeta ¶
func ParseDocumentMeta(zm goziputils.ZipMap, tf template.FuncMap) (*documentMeta, error)
TODO: use xml parsing instead of regex
Types ¶
type Relationship ¶
type Relationship struct {
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/relationships Relationships"`
Relationships []relationshipDetail `xml:"Relationship"`
}
func ParseRelationship ¶
func ParseRelationship(data []byte) (*Relationship, error)
func (*Relationship) AddMediaToRels ¶
func (r *Relationship) AddMediaToRels(media []MediaRel)
func (*Relationship) ToXml ¶
func (r *Relationship) ToXml() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.