oxml

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultEncode

func DefaultEncode(object interface{}) (string, error)

DefaultEncode returns an encoded xml string.

func RelationshipPath

func RelationshipPath(path string) string

RelationshipPath returns the relationship file path that is relative to the given file.

func TargetPath

func TargetPath(src, dst Part) string

TargetPath returns the relative path from source part file to target part file.

Types

type AppProps

type AppProps struct {
	XMLName     xml.Name `xml:"Properties"`
	Namespace   string   `xml:"xmlns,attr"`
	VtNameSpace string   `xml:"xmlns:vt,attr"`
	Application string
}

AppProps is a on of file properties for Excel.

func NewAppProps

func NewAppProps() *AppProps

NewAppProps creates new core file properties.

func (*AppProps) Content

func (ap *AppProps) Content() string

Content returns an xml string generated from object contents.

func (*AppProps) Path

func (ap *AppProps) Path() string

Path returns the file path in the archive.

type ContentTypes

type ContentTypes struct {
	XMLName   xml.Name `xml:"Types"`
	Namespace string   `xml:"xmlns,attr"`
	Defaults  []DefaultType
	Overrides []OverrideType
}

ContentTypes specify the content types in the archive.

func NewContentTypes

func NewContentTypes() *ContentTypes

NewContentTypes creates a new content types.

func (*ContentTypes) AddDefault

func (c *ContentTypes) AddDefault(item DefaultType)

AddDefault adds a default type.

func (*ContentTypes) AddOverride

func (c *ContentTypes) AddOverride(item OverrideType)

AddOverride adds an override type.

func (*ContentTypes) Content

func (c *ContentTypes) Content() string

Content returns an xml string generated from object contents.

func (*ContentTypes) Path

func (c *ContentTypes) Path() string

Path returns the file path in the archive.

type CoreProps

type CoreProps struct {
	XMLName           xml.Name `xml:"cp:coreProperties"`
	PropNamespace     string   `xml:"xmlns:cp,attr"`
	DcNameSpace       string   `xml:"xmlns:dc,attr"`
	DcTermsNameSpace  string   `xml:"xmlns:dcterms,attr"`
	DcmiTypeNameSpace string   `xml:"xmlns:dcmitype,attr"`
	XSINameSpace      string   `xml:"xmlns:xsi,attr"`
}

CoreProps is 'Core Properties' that is defined in OPC.

func NewCoreProps

func NewCoreProps() *CoreProps

NewCoreProps creates new core file properties.

func (*CoreProps) Content

func (cp *CoreProps) Content() string

Content returns an xml string generated from object contents.

func (*CoreProps) Path

func (cp *CoreProps) Path() string

Path returns the file path in the archive.

type DefaultType

type DefaultType struct {
	XMLName     xml.Name `xml:"Default"`
	Extension   string   `xml:",attr"`
	ContentType string   `xml:",attr"`
}

DefaultType is the content type per extension.

type Drawing

type Drawing struct {
	XMLName         xml.Name `xml:"xdr:wsDr"`
	Namespace       string   `xml:"xmlns:xdr,attr"`
	AnchorNamespace string   `xml:"xmlns:a,attr"`
	Shapes          []shape.Shape
	// contains filtered or unexported fields
}

Drawing is a drawing object.

func NewDrawing

func NewDrawing(path string) *Drawing

NewDrawing creates new drawing.

func (*Drawing) AddShape

func (d *Drawing) AddShape(s shape.Shape)

AddShape adds a shape to this.

func (*Drawing) Content

func (d *Drawing) Content() string

Content returns an xml string generated from object contents.

func (*Drawing) Path

func (d *Drawing) Path() string

Path returns the file path in the archive.

func (*Drawing) UnshiftShape added in v0.0.3

func (d *Drawing) UnshiftShape(s shape.Shape)

UnshiftShape inserts a shape into the head of shape list.

type DrawingRel

type DrawingRel struct {
	XMLName xml.Name `xml:"drawing"`
	ID      string   `xml:"r:id,attr"`
}

DrawingRel is a relationships of the drawing.

type OverrideType

type OverrideType struct {
	XMLName     xml.Name `xml:"Override"`
	PartName    string   `xml:",attr"`
	ContentType string   `xml:",attr"`
}

OverrideType is the content type per file.

type Package

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

Package implements OpenXML SpreadSheetPackage.

func (*Package) Add

func (p *Package) Add(part Part)

Add adds the given part into this package.

func (*Package) List

func (p *Package) List() []string

List lists the all filepaths in this package.

func (*Package) Packaging

func (p *Package) Packaging() (*bytes.Buffer, error)

Packaging creates a new Excel file from the given files.

type Part

type Part interface {
	Path() string
	Content() string
}

Part is a part of OpenXML SpreadSheetPackage.

type Relationship

type Relationship struct {
	XMLName xml.Name `xml:"Relationship"`
	ID      string   `xml:"Id,attr"`
	Type    string   `xml:"Type,attr"`
	Target  string   `xml:"Target,attr"`
}

Relationship has a relation between a source part and a target part.

type Relationships

type Relationships struct {
	XMLName   xml.Name `xml:"Relationships"`
	Namespace string   `xml:"xmlns,attr"`
	Items     []Relationship
	// contains filtered or unexported fields
}

Relationships contains zero or more relationship.

func NewRelationships

func NewRelationships(path string) *Relationships

NewRelationships creates new relationships.

func (*Relationships) Add

func (r *Relationships) Add(item Relationship)

Add adds a relationship.

func (*Relationships) Content

func (r *Relationships) Content() string

Content returns an xml string generated from object contents.

func (*Relationships) Path

func (r *Relationships) Path() string

Path returns the file path in the archive.

type Sheet

type Sheet struct {
	XMLName        xml.Name `xml:"sheet"`
	Name           string   `xml:"name,attr"`
	SheetID        string   `xml:"sheetId,attr"`
	RelationshipID string   `xml:"r:id,attr"`
}

Sheet is a relationship of the worksheet.

type SheetData

type SheetData struct {
	XMLName xml.Name `xml:"sheetData"`
}

SheetData is a struct.

type SheetFormat

type SheetFormat struct {
	XMLName            xml.Name `xml:"sheetFormatPr"`
	DefaultColumnWidth string   `xml:"defaultColWidth,attr,omitempty"`
	DefaultRowHeight   string   `xml:"defaultRowHeight,attr,omitempty"`
	CustomHeight       string   `xml:"customHeight,attr,omitempty"`
}

SheetFormat is a struct.

type Sheets

type Sheets struct {
	XMLName xml.Name `xml:"sheets"`
	Items   []Sheet
}

Sheets is a slice of Sheet.

type Spreadsheet

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

Spreadsheet creates a consumable Excel file.

func NewSpreadsheet

func NewSpreadsheet() *Spreadsheet

NewSpreadsheet creates a new spread sheet.

func (*Spreadsheet) AddShape

func (ss *Spreadsheet) AddShape(s shape.Shape)

AddShape adds a shape into the drawing collection of this spreadsheet.

func (*Spreadsheet) Dump

func (ss *Spreadsheet) Dump(filename string)

Dump writes out the contents into the new Excel file

func (*Spreadsheet) List

func (ss *Spreadsheet) List() []string

List lists the all paths in this file.

func (*Spreadsheet) UnshiftShape added in v0.0.3

func (ss *Spreadsheet) UnshiftShape(s shape.Shape)

UnshiftShape adds a shape into the drawing collection of this spreadsheet. The given shape will be drawn under the existing shapes.

type Workbook

type Workbook struct {
	XMLName      xml.Name `xml:"workbook"`
	Namespace    string   `xml:"xmlns,attr"`
	RelNameSpace string   `xml:"xmlns:r,attr"`
	Sheets       Sheets
	// contains filtered or unexported fields
}

Workbook contains one or more worksheet.

func NewWorkbook

func NewWorkbook(path string) *Workbook

NewWorkbook creates new workbook.

func (*Workbook) Add

func (wb *Workbook) Add(name, sheetID string, target Part)

Add adds a sheet.

func (*Workbook) Content

func (wb *Workbook) Content() string

Content returns an xml string generated from object contents.

func (*Workbook) Path

func (wb *Workbook) Path() string

Path returns the file path in the archive.

func (*Workbook) Relationships

func (wb *Workbook) Relationships() *Relationships

Relationships returns the relationships associated to this.

type Worksheet

type Worksheet struct {
	XMLName      xml.Name `xml:"worksheet"`
	Namespace    string   `xml:"xmlns,attr"`
	RelNameSpace string   `xml:"xmlns:r,attr"`
	SheetFormat  SheetFormat
	SheetData    SheetData
	DrawingRels  []DrawingRel
	// contains filtered or unexported fields
}

Worksheet is a worksheet.

func NewWorksheet

func NewWorksheet(path string) *Worksheet

NewWorksheet creates new worksheet.

func (*Worksheet) AddDrawing

func (ws *Worksheet) AddDrawing(target Part)

AddDrawing adds a drawing relationship into this.

func (*Worksheet) Content

func (ws *Worksheet) Content() string

Content returns an xml string generated from object contents.

func (*Worksheet) Path

func (ws *Worksheet) Path() string

Path returns the file path in the archive.

func (*Worksheet) Relationships

func (ws *Worksheet) Relationships() *Relationships

Relationships returns the relationships associated to this.

func (*Worksheet) SetDefaultCellSize

func (ws *Worksheet) SetDefaultCellSize(w, h string)

SetDefaultCellSize sets the default size of cell.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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