Documentation
¶
Overview ¶
package excel contain a excel document.
Index ¶
- Constants
- Variables
- func FormatDatetime(f *numFmt, data []byte) (out string)
- func FormatDefault(f *numFmt, data []byte) (out string)
- func FormatDimension(row, column int) (s string)
- func FormatFloat(f *numFmt, data []byte) (out string)
- func FormatInteger(f *numFmt, data []byte) (out string)
- func FormatStandard(f *numFmt, data []byte) (out string)
- func NewCellStyleXf(nf *numFmt) (f *cellStyleXf)
- func NewCellXf(nf *numFmt) (f *cellXf)
- func NewNumFmt(numFmtId, code, goFormat string, ...) (f *numFmt)
- func NewSimpleWriter(doc *Document) (w *simplewriter)
- func NodeContent(r io.Reader, tag []byte) (contents []string, err error)
- func ParseReference(value []byte) (column, row int, err error)
- func WriteSimple(outputFile string, doc *Document) (err error)
- type Attributes
- type Cell
- func (c *Cell) From(other *Cell)
- func (c *Cell) SetCellStyleXf(xf *cellStyleXf) (out *Cell)
- func (c *Cell) SetCellXf(xf *cellXf) (out *Cell)
- func (c *Cell) SetType(t Type) (out *Cell)
- func (c *Cell) SetValue(ss *SharedStrings, v string) (out *Cell)
- func (c *Cell) Value(ss *SharedStrings, applyStyle bool) (cell string)
- type ColumnUpdate
- type ContentType
- type Dimension
- type Document
- type Elements
- type File
- type Files
- type Row
- func (r Row) Cell(idx int) (c *Cell)
- func (r Row) Indeces(pick []string, ss *SharedStrings, applyStyle bool, translate map[string]string) (indeces []int, err error)
- func (r Row) Pick(pick []int, ss *SharedStrings, applyStyle bool) (row []string)
- func (r Row) Value(ss *SharedStrings, applyStyle bool) (row []string)
- type SharedStrings
- type Sheet
- func (s *Sheet) AddColumns(cols []ColumnUpdate)
- func (s *Sheet) AppendEmptyRow(width int) (r []Cell)
- func (s *Sheet) AppendRow() (r *newrow)
- func (s *Sheet) Cell(row, col int) (c *Cell)
- func (s *Sheet) CellByRef(ref string) (cell *Cell, err error)
- func (s *Sheet) ColumnByTitle(row int, title string) (column int, err error)
- func (s *Sheet) ReadFrom(r io.Reader) (n int64, err error)
- func (s *Sheet) Row(row int) (r Row)
- func (s *Sheet) SharedStrings() (ss *SharedStrings)
- func (s *Sheet) Styles() (ss *Styles)
- func (s *Sheet) WriteTo(w io.Writer) (n int64, err error)
- type Styles
- func (s *Styles) AddCellStyleXf(xf *cellStyleXf)
- func (s *Styles) AddCellXf(xf *cellXf)
- func (s *Styles) AddNumFmt(nf *numFmt)
- func (s *Styles) GetCellStyleXf(idx int) (xf *cellStyleXf)
- func (s *Styles) GetCellStyleXfByFormat(format string) (xf *cellStyleXf)
- func (s *Styles) GetCellXf(idx int) (xf *cellXf)
- func (s *Styles) GetCellXfByFormat(format string) (xf *cellXf)
- func (s *Styles) GetNumFmt(id string) (nf *numFmt)
- func (s *Styles) GetNumFmtByFormat(format string) (nf *numFmt)
- type Type
- type Workbook
- func (w *Workbook) AddSheet(name string) (s *Sheet, err error)
- func (w *Workbook) ImportSheet(name string, s *Sheet, addCols []ColumnUpdate) (t *Sheet, err error)
- func (w *Workbook) SharedStrings() (ss *SharedStrings)
- func (w *Workbook) Sheet(name string) (s *Sheet, n int64, err error)
- func (w *Workbook) Sheets() (s []*Sheet)
- func (w *Workbook) Styles() (ss *Styles)
Constants ¶
View Source
const ( Spreadsheet = "http://schemas.openxmlformats.org/spreadsheetml/2006/main" Relationships = "http://schemas.openxmlformats.org/package/2006/relationships" RelationshipsDoc = "http://schemas.openxmlformats.org/officeDocument/2006/relationships" OfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" RelationshipStyles = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" RelationshipsWorksheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" RelationshipsTheme = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ContentTypes = "http://schemas.openxmlformats.org/package/2006/content-types" CoreProperties = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" ExtendedProperties = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" MarkupCompatibility = "http://schemas.openxmlformats.org/markup-compatibility/2006" X14ac = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" X16r2 = "http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" X15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" AppVersion = "16.0300" Creator = "User" // TODO Set to proper value at startup LastModifiedBy = Creator // TODO Set to proper value at startup )
View Source
const ( Boolean Type = 'b' Date = 'd' Error = 'e' Inline = 'i' Number = 'n' String = 's' Formula = 'f' )
Variables ¶
View Source
var ( // See https://docs.microsoft.com/en-us/office/open-xml/structure-of-a-spreadsheetml-document EmbeddedExcel = regexp.MustCompile(`\.xlsx$`) // Only process top levele EXCEL files. EmbeddedZIP = regexp.MustCompile(`\.zip$`) // Only process top levele EXCEL files. )
View Source
var ( ErrUnknownFile = errors.New("Missing _rels/.rels file") ErrMissingRels = errors.New("Missing _rels/.rels file") ErrMissingWorkbook = errors.New("Missing workbook file") ErrMissingStyles = errors.New("Missing styles file") ErrInvalidSpans = errors.New("Invalid spans attribute format") ErrInvalidDimension = errors.New("Invalid dimension attribute format") ErrInvalidReference = errors.New("Invalid reference attribute format") ErrDuplicateSheet = errors.New("Duplicate sheet") ErrUnknownSheet = errors.New("Unknown sheet") ErrArgumentInconsictency = errors.New("Inconsistent arguments") )
Functions ¶
func FormatDatetime ¶
func FormatDefault ¶
func FormatDimension ¶
func FormatFloat ¶
func FormatInteger ¶
func FormatStandard ¶
func NewCellStyleXf ¶
func NewCellStyleXf(nf *numFmt) (f *cellStyleXf)
func NewSimpleWriter ¶
func NewSimpleWriter(doc *Document) (w *simplewriter)
func ParseReference ¶
func WriteSimple ¶
Types ¶
type Attributes ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
func (*Cell) SetCellStyleXf ¶
type ColumnUpdate ¶
type ContentType ¶
type ContentType string
type Dimension ¶
type Dimension struct {
ColumnStart, RowStart, ColumnEnd, RowEnd int
}
func ParseDimension ¶
type Document ¶
type Document struct { Workbook *Workbook // contains filtered or unexported fields }
func NewDocument ¶
func NewDocument() (doc *Document)
type Elements ¶
type Elements []Attributes
func ChildAttributes ¶
func (Elements) Get ¶
func (e Elements) Get(key, value string) (element Attributes)
type File ¶
func (*File) QuerySelectorAll ¶
func (f *File) QuerySelectorAll(tagname string) (elements []Attributes, err error)
type SharedStrings ¶
type SharedStrings struct {
// contains filtered or unexported fields
}
func (*SharedStrings) Get ¶
func (s *SharedStrings) Get(idx int) (v string)
func (*SharedStrings) GetFromValue ¶
func (s *SharedStrings) GetFromValue(value []byte) (v string)
func (*SharedStrings) GetIdx ¶
func (s *SharedStrings) GetIdx(v string) (idx int)
GetIdx return 1-offset shared strings index. If 0 is returned no string matched.
type Sheet ¶
type Sheet struct { Attributes Attributes Dimension Dimension Rows [][]Cell // contains filtered or unexported fields }
Sheet of an Excel workbook, providing access to Cells and Rows.
func (*Sheet) AddColumns ¶
func (s *Sheet) AddColumns(cols []ColumnUpdate)
AddColumns add new column(s) to the current sheet.
func (*Sheet) AppendEmptyRow ¶
func (*Sheet) ColumnByTitle ¶
ColumnByTitle
func (*Sheet) SharedStrings ¶
func (s *Sheet) SharedStrings() (ss *SharedStrings)
SharedStrings return a reference to the sharedstrings(.xml)
type Styles ¶
type Styles struct {
// contains filtered or unexported fields
}
Styles represent Excel styles(.xml)
func (*Styles) AddCellStyleXf ¶
func (s *Styles) AddCellStyleXf(xf *cellStyleXf)
func (*Styles) GetCellStyleXf ¶
func (*Styles) GetCellStyleXfByFormat ¶
func (*Styles) GetCellXfByFormat ¶
func (*Styles) GetNumFmtByFormat ¶
type Workbook ¶
type Workbook struct {
// contains filtered or unexported fields
}
Workbook represent an Excel Workbook(.xml).
func (*Workbook) ImportSheet ¶
Import sheet (deep clone).
func (*Workbook) SharedStrings ¶
func (w *Workbook) SharedStrings() (ss *SharedStrings)
SharedStrings return a reference to the sharedstrings(.xml)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.