Documentation ¶
Overview ¶
Package gooxml provides creation, reading, and writing of ECMA 376 Open Office XML documents, spreadsheets and presentations. It is still early in development, but is progressing quickly. This library takes a slightly different approach from others, in that it starts by trying to support all of the ECMA-376 standard when marshaling/unmarshaling XML documents. From there it adds wrappers around the ECMA-376 derived types that provide a more convenient interface.
The raw XML based types reside in the ```schema/``` directory. These types are always accessible from the wrapper types via a ```X()``` method that returns the raw type. Except for the base documents (document.Document, spreadsheet.Workbook and presentation.Presentation), the other wrapper types are value types with non-pointer methods. They exist solely to modify and return data from one or more XML types.
The packages of interest are baliance.com/gooxml/document, baliance/gooxml/spreadsheet and baliance.com/gooxml/presentation.
Example (Document) ¶
package main import ( "baliance.com/gooxml/document" ) func main() { // see the baliance.com/gooxml/document documentation or _examples/document // for more examples doc := document.New() doc.AddParagraph().AddRun().AddText("Hello World!") doc.SaveToFile("document.docx") }
Output:
Index ¶
- func AddPreserveSpaceAttr(se *xml.StartElement, s string)
- func Bool(v bool) *bool
- func Float64(v float64) *float64
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func NeedsSpacePreserve(s string) bool
- func RegisterConstructor(ns, name string, fn interface{})
- func String(v string) *string
- func Uint32(v uint32) *uint32
- func Uint64(v uint64) *uint64
- type Any
- type XSDAny
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPreserveSpaceAttr ¶
func AddPreserveSpaceAttr(se *xml.StartElement, s string)
AddPreserveSpaceAttr adds an xml:space="preserve" attribute to a start element if it is required for the string s.
func NeedsSpacePreserve ¶
NeedsSpacePreserve returns true if the string has leading or trailing space.
func RegisterConstructor ¶
func RegisterConstructor(ns, name string, fn interface{})
RegisterConstructor registers a constructor function used for unmarshaling xsd:any elements.
Types ¶
type Any ¶
type Any interface { MarshalXML(e *xml.Encoder, start xml.StartElement) error UnmarshalXML(d *xml.Decoder, start xml.StartElement) error }
Any is the interface used for marshaling/unmarshaling xsd:any
func CreateElement ¶
func CreateElement(start xml.StartElement) (Any, error)
CreateElement creates an element with the given namespace and name. It is used to unmarshal some xsd:any elements to the appropriate concrete type.
type XSDAny ¶
XSDAny is used to marshal/unmarshal xsd:any types in the OOXML schema.
func (*XSDAny) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface.
func (*XSDAny) UnmarshalXML ¶
UnmarshalXML implements the xml.Unmarshaler interface.
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
cmd
|
|
Package document provides creation, reading, and writing of ECMA 376 Open Office XML documents.
|
Package document provides creation, reading, and writing of ECMA 376 Open Office XML documents. |
schema
|
|