common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// Common
	OfficeDocumentType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
	StylesType         = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
	ThemeType          = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
	ThemeContentType   = "application/vnd.openxmlformats-officedocument.theme+xml"
	SettingsType       = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
	ImageType          = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
	CommentsType       = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
	ThumbnailType      = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"

	ExtendedPropertiesType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
	CorePropertiesType     = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"

	// SML
	WorksheetType            = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
	SharedStringsContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
	SharedStingsType         = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"

	// WML
	HeaderType      = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
	FooterType      = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
	NumberingType   = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
	FontTableType   = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
	WebSettingsType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
	FootNotesType   = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
	EndNotesType    = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"

	// PML
	SlideType                   = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
	SlideContentType            = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml"
	SlideMasterRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
	SlideMasterContentType      = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"
	SlideLayoutType             = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
	SlideLayoutContentType      = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"
)

Consts for content types used throughout the package

Variables

This section is empty.

Functions

This section is empty.

Types

type AppProperties

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

AppProperties contains properties specific to the document and the application that created it.

func NewAppProperties

func NewAppProperties() AppProperties

NewAppProperties constructs a new AppProperties.

func (AppProperties) Application

func (a AppProperties) Application() string

Application returns the name of the application that created the document. For gooxml created documents, it defaults to baliance.com/gooxml

func (AppProperties) ApplicationVersion

func (a AppProperties) ApplicationVersion() string

ApplicationVersion returns the version of the application that created the document.

func (AppProperties) Company

func (a AppProperties) Company() string

Company returns the name of the company that created the document. For gooxml created documents, it defaults to baliance.com/gooxml

func (AppProperties) SetApplication

func (a AppProperties) SetApplication(s string)

SetApplication sets the name of the application that created the document.

func (AppProperties) SetApplicationVersion

func (a AppProperties) SetApplicationVersion(s string)

SetApplicationVersion sets the version of the application that created the document.

func (AppProperties) SetCompany

func (a AppProperties) SetCompany(s string)

SetCompany sets the name of the company that created the document.

func (AppProperties) X

X returns the inner wrapped XML type.

type ContentTypes

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

ContentTypes is the top level "[Content_Types].xml" in a zip package.

func NewContentTypes

func NewContentTypes() ContentTypes

NewContentTypes returns a wrapper around a newly constructed content-types.

func (ContentTypes) AddDefault

func (c ContentTypes) AddDefault(fileExtension string, contentType string)

AddDefault registers a default content type for a given file extension.

func (ContentTypes) AddOverride

func (c ContentTypes) AddOverride(path, contentType string)

AddOverride adds an override content type for a given path name.

func (ContentTypes) X

X returns the inner raw content types.

type CoreProperties

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

CoreProperties contains document specific properties.

Example
package main

import (
	"fmt"
	"time"

	"baliance.com/gooxml/document"
)

func main() {
	doc, _ := document.Open("document.docx")
	cp := doc.CoreProperties
	// Reading Properties
	fmt.Println("Title:", cp.Title())
	fmt.Println("Author:", cp.Author())
	fmt.Println("Description:", cp.Description())
	fmt.Println("Last Modified By:", cp.LastModifiedBy())
	fmt.Println("Category:", cp.Category())
	fmt.Println("Content Status:", cp.ContentStatus())
	fmt.Println("Created:", cp.Created())
	fmt.Println("Modified:", cp.Modified())

	// Setting Properties
	cp.SetTitle("CP Invoices")
	cp.SetAuthor("John Doe")
	cp.SetCategory("Invoices")
	cp.SetContentStatus("Draft")
	cp.SetLastModifiedBy("Jane Smith")
	cp.SetCreated(time.Now())
	cp.SetModified(time.Now())
	doc.SaveToFile("document.docx")
}
Output:

func NewCoreProperties

func NewCoreProperties() CoreProperties

NewCoreProperties constructs a new CoreProperties.

func (CoreProperties) Author

func (c CoreProperties) Author() string

Author returns the author of the document

func (CoreProperties) Category

func (c CoreProperties) Category() string

ContentStatus returns the category of the document

func (CoreProperties) ContentStatus

func (c CoreProperties) ContentStatus() string

ContentStatus returns the content status of the document (e.g. "Final", "Draft")

func (CoreProperties) Created

func (c CoreProperties) Created() time.Time

Created returns the time that the document was created.

func (CoreProperties) Description

func (c CoreProperties) Description() string

Description returns the description of the document

func (CoreProperties) LastModifiedBy

func (c CoreProperties) LastModifiedBy() string

LastModifiedBy returns the name of the last person to modify the document

func (CoreProperties) Modified

func (c CoreProperties) Modified() time.Time

Modified returns the time that the document was modified.

func (CoreProperties) SetAuthor

func (c CoreProperties) SetAuthor(s string)

SetAuthor records the author of the document.

func (CoreProperties) SetCategory

func (c CoreProperties) SetCategory(s string)

SetCategory records the category of the document.

func (CoreProperties) SetContentStatus

func (c CoreProperties) SetContentStatus(s string)

SetCategory records the category of the document.

func (CoreProperties) SetCreated

func (c CoreProperties) SetCreated(t time.Time)

SetCreated sets the time that the document was created.

func (CoreProperties) SetDescription

func (c CoreProperties) SetDescription(s string)

SetDescription records the description of the document.

func (CoreProperties) SetLastModifiedBy

func (c CoreProperties) SetLastModifiedBy(s string)

SetLastModifiedBy records the last person to modify the document.

func (CoreProperties) SetModified

func (c CoreProperties) SetModified(t time.Time)

SetModified sets the time that the document was modified.

func (CoreProperties) SetTitle

func (c CoreProperties) SetTitle(s string)

SetTitle records the title of the document.

func (CoreProperties) Title

func (c CoreProperties) Title() string

Title returns the Title of the document

func (CoreProperties) X

X returns the inner wrapped XML type.

type DocBase

type DocBase struct {
	ContentTypes   ContentTypes
	AppProperties  AppProperties
	Rels           Relationships
	CoreProperties CoreProperties
	Thumbnail      image.Image // thumbnail preview of the document

	ExtraFiles []ExtraFile
	TmpPath    string // path where temporary files are stored when opening documents
}

DocBase is the type embedded in in the Document/Workbook/Presentation types that contains members common to all.

func (*DocBase) AddExtraFileFromZip

func (d *DocBase) AddExtraFileFromZip(f *zip.File) error

AddExtraFileFromZip is used when reading an unsupported file from an OOXML file. This ensures that unsupported file content will at least round-trip correctly.

func (*DocBase) WriteExtraFiles

func (d *DocBase) WriteExtraFiles(z *zip.Writer) error

WriteExtraFiles writes the extra files to the zip package.

type ExtraFile

type ExtraFile struct {
	ZipPath  string
	DiskPath string
}

ExtraFile is an unsupported file type extracted from, or to be written to a zip package

type Relationship

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

Relationship is a relationship within a .rels file.

func NewRelationship

func NewRelationship() Relationship

NewRelationship constructs a new relationship.

func (Relationship) ID

func (r Relationship) ID() string

ID returns the ID of a relationship.

func (Relationship) SetTarget

func (r Relationship) SetTarget(s string)

SetTarget set the target (path) of a relationship.

func (Relationship) String

func (r Relationship) String() string

func (Relationship) Target

func (r Relationship) Target() string

Target returns the target (path) of a relationship.

func (Relationship) Type

func (r Relationship) Type() string

Type returns the type of a relationship.

func (Relationship) X

X returns the inner wrapped XML type.

type Relationships

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

Relationships represents a .rels file.

func NewRelationships

func NewRelationships() Relationships

NewRelationships creates a new relationship wrapper.

func (Relationships) AddRelationship

func (r Relationships) AddRelationship(target, ctype string) Relationship

AddRelationship adds a relationship.

func (Relationships) Clear

func (r Relationships) Clear()

Clear removes any existing relationships.

func (Relationships) FindRIDForN

func (r Relationships) FindRIDForN(i int, t string) string

FindRIDForN returns the relationship ID for the i'th relationship of type t.

func (Relationships) Relationships

func (r Relationships) Relationships() []Relationship

Relationships returns a slice of all of the relationships.

func (Relationships) X

X returns the underlying raw XML data.

type Theme

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

Theme is a drawingml theme.

func NewTheme

func NewTheme() Theme

NewTheme constructs a new theme.

func (Theme) X

func (t Theme) X() *dml.Theme

X returns the inner wrapped XML type.

Jump to

Keyboard shortcuts

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