spreadsheet

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Copyright 2017 Baliance. All rights reserved.

Use of this source code is governed by the terms of the Affero GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. A commercial license can be purchased by contacting sales@baliance.com.

Index

Examples

Constants

Variables

View Source
var ErrorNotFound = errors.New("not found")

ErrorNotFound is returned when something is not found

Functions

func PasswordHash added in v0.4.0

func PasswordHash(s string) string

PasswordHash returns the password hash for a workbook using the modified spreadsheetML password hash that is compatible with Excel.

Types

type AbsoluteAnchor added in v0.2.0

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

AbsoluteAnchor has a fixed top-left corner in distance units as well as a fixed height/width.

func (AbsoluteAnchor) BottomRight added in v0.2.0

func (a AbsoluteAnchor) BottomRight() CellMarker

BottomRight is a no-op.

func (AbsoluteAnchor) MoveTo added in v0.2.0

func (a AbsoluteAnchor) MoveTo(x, y int32)

MoveTo is a no-op.

func (AbsoluteAnchor) SetColOffset added in v0.2.0

func (a AbsoluteAnchor) SetColOffset(m measurement.Distance)

SetColOffset sets the column offset of the top-left of the image in fixed units.

func (AbsoluteAnchor) SetHeight added in v0.2.0

func (a AbsoluteAnchor) SetHeight(h measurement.Distance)

SetHeight sets the height of the anchored object.

func (AbsoluteAnchor) SetHeightCells added in v0.2.0

func (a AbsoluteAnchor) SetHeightCells(int32)

SetHeightCells is a no-op.

func (AbsoluteAnchor) SetRowOffset added in v0.2.0

func (a AbsoluteAnchor) SetRowOffset(m measurement.Distance)

SetRowOffset sets the row offset of the top-left of the image in fixed units.

func (AbsoluteAnchor) SetWidth added in v0.2.0

func (a AbsoluteAnchor) SetWidth(w measurement.Distance)

SetWidth sets the width of the anchored object.

func (AbsoluteAnchor) SetWidthCells added in v0.2.0

func (a AbsoluteAnchor) SetWidthCells(int32)

SetWidthCells is a no-op.

func (AbsoluteAnchor) TopLeft added in v0.2.0

func (a AbsoluteAnchor) TopLeft() CellMarker

TopLeft is a no-op.

func (AbsoluteAnchor) Type added in v0.2.0

func (a AbsoluteAnchor) Type() AnchorType

Type returns the type of anchor

type Anchor added in v0.2.0

type Anchor interface {
	// BottomRight returns the CellMaker for the bottom right corner of the
	// anchor.
	BottomRight() CellMarker
	// TopLeft returns the CellMaker for the top left corner of the anchor.
	TopLeft() CellMarker
	// MoveTo repositions the anchor without changing the objects size.
	MoveTo(col, row int32)

	// SetWidth sets the width of the anchored object. It is not compatible with
	// SetWidthCells.
	SetWidth(w measurement.Distance)
	// SetWidthCells sets the height the anchored object by moving the right
	// hand side. It is not compatible with SetWidth.
	SetWidthCells(w int32)

	// SetHeight sets the height of the anchored object. It is not compatible
	// with SetHeightCells.
	SetHeight(w measurement.Distance)
	// SetHeightCells sets the height the anchored object by moving the bottom.
	// It is not compatible with SetHeight.
	SetHeightCells(h int32)

	// SetColOffset sets the column offset of the top-left anchor.
	SetColOffset(m measurement.Distance)
	// SetRowOffset sets the row offset of the top-left anchor.
	SetRowOffset(m measurement.Distance)

	// Type returns the type of anchor
	Type() AnchorType
}

Anchor is the interface implemented by anchors. It's modeled after the most common anchor (Two cell variant with a from/to position), but will also be used for one-cell anchors. In that case the only non-noop methods are TopLeft/MoveTo/SetColOffset/SetRowOffset.

type AnchorType added in v0.2.0

type AnchorType byte

AnchorType is the type of anchor.

const (
	AnchorTypeAbsolute AnchorType = iota
	AnchorTypeOneCell
	AnchorTypeTwoCell
)

AnchorType constants

type Border added in v0.2.0

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

Border is a cell border configuraton.

func (Border) Index added in v0.2.0

func (b Border) Index() uint32

Index returns the index of the border for use with a cell style.

func (Border) InitializeDefaults added in v0.2.0

func (b Border) InitializeDefaults()

InitializeDefaults initializes a border to its defaulte empty values.

func (Border) SetBottom added in v0.2.0

func (b Border) SetBottom(style sml.ST_BorderStyle, c color.Color)

func (Border) SetDiagonal added in v0.2.0

func (b Border) SetDiagonal(style sml.ST_BorderStyle, c color.Color, up, down bool)

func (Border) SetLeft added in v0.2.0

func (b Border) SetLeft(style sml.ST_BorderStyle, c color.Color)

func (Border) SetRight added in v0.2.0

func (b Border) SetRight(style sml.ST_BorderStyle, c color.Color)

func (Border) SetTop added in v0.2.0

func (b Border) SetTop(style sml.ST_BorderStyle, c color.Color)

func (Border) X added in v0.2.0

func (b Border) X() *sml.CT_Border

X returns the inner wrapped XML type.

type Cell

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

Cell is a single cell within a sheet.

func (c Cell) AddHyperlink(url string)

AddHyperlink creates and sets a hyperlink on a cell.

func (Cell) Clear added in v0.2.0

func (c Cell) Clear()

Clear clears the cell's value and type.

func (Cell) Column added in v0.6.0

func (c Cell) Column() (string, error)

Column returns the cell column

func (Cell) GetCachedFormulaResult added in v0.3.0

func (c Cell) GetCachedFormulaResult() string

GetCachedFormulaResult returns the cached formula result if it exists. If the cell type is not a formula cell, the result will be the cell value if it's a string/number/bool cell.

func (Cell) GetFormattedValue added in v0.3.0

func (c Cell) GetFormattedValue() string

GetFormattedValue returns the formatted cell value as it would appear in Excel. This involves determining the format string to apply, parsing it, and then formatting the value according to the format string. This should only be used if you care about replicating what Excel would show, otherwise GetValueAsNumber()/GetValueAsTime

func (Cell) GetFormula added in v0.3.0

func (c Cell) GetFormula() string

GetFormula returns the formula for a cell.

func (Cell) GetRawValue added in v0.3.0

func (c Cell) GetRawValue() (string, error)

func (Cell) GetString added in v0.2.0

func (c Cell) GetString() string

GetString returns the string in a cell if it's an inline or string table string. Otherwise it returns an empty string.

func (Cell) GetValueAsBool added in v0.2.0

func (c Cell) GetValueAsBool() (bool, error)

GetValueAsBool retrieves the cell's value as a boolean

func (Cell) GetValueAsNumber added in v0.2.0

func (c Cell) GetValueAsNumber() (float64, error)

GetValueAsNumber retrieves the cell's value as a number

func (Cell) GetValueAsTime added in v0.2.0

func (c Cell) GetValueAsTime() (time.Time, error)

GetValueAsTime retrieves the cell's value as a time. There is no difference in SpreadsheetML between a time/date cell other than formatting, and that typically a date cell won't have a fractional component. GetValueAsTime will work for date cells as well.

func (Cell) HasFormula added in v0.3.0

func (c Cell) HasFormula() bool

HasFormula returns true if the cell has an asoociated formula.

func (Cell) IsBool added in v0.3.0

func (c Cell) IsBool() bool

IsBool returns true if the cell is a boolean type cell.

func (Cell) IsEmpty added in v0.3.0

func (c Cell) IsEmpty() bool

IsEmpty returns true if the cell is empty.

func (Cell) IsNumber added in v0.3.0

func (c Cell) IsNumber() bool

IsNumber returns true if the cell is a number type cell.

func (Cell) Reference added in v0.2.0

func (c Cell) Reference() string

Reference returns the cell reference (e.g. "A4"). This is not required, however both gooxml and Excel will always set it.

func (Cell) SetBool

func (c Cell) SetBool(v bool)

SetBool sets the cell type to boolean and the value to the given boolean value.

func (Cell) SetCachedFormulaResult added in v0.4.0

func (c Cell) SetCachedFormulaResult(s string)

SetCachedFormulaResult sets the cached result of a formula. This is normally not needed but is used internally when expanding an array formula.

func (Cell) SetDate added in v0.2.0

func (c Cell) SetDate(d time.Time)

SetDate sets the cell value to a date. It's stored as the number of days past th sheet epoch. When we support v5 strict, we can store an ISO 8601 date string directly, however that's not allowed with v5 transitional (even though it works in Excel). The cell is not styled via this method, so it will display as a number. SetDateWithStyle should normally be used instead.

Example
package main

import (
	"time"

	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()
	cell := sheet.Cell("A1")
	// set our date value
	cell.SetDate(time.Now())

	// then display it with a date style
	dateStyle := wb.StyleSheet.AddCellStyle()
	dateStyle.SetNumberFormatStandard(spreadsheet.StandardFormatDate)
	cell.SetStyle(dateStyle)
}
Output:

func (Cell) SetDateWithStyle added in v0.2.0

func (c Cell) SetDateWithStyle(d time.Time)

SetDateWithStyle sets a date with the default date style applied.

Example
package main

import (
	"time"

	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()
	cell := sheet.Cell("A1")

	cell.SetDateWithStyle(time.Now())
}
Output:

func (Cell) SetFormulaArray added in v0.4.0

func (c Cell) SetFormulaArray(s string)

SetFormulaArray sets the cell type to formula array, and the raw formula to the given string. This is equivlent to entering a formula and pressing Ctrl+Shift+Enter in Excel.

func (Cell) SetFormulaRaw

func (c Cell) SetFormulaRaw(s string)

SetFormulaRaw sets the cell type to formula, and the raw formula to the given string

func (Cell) SetFormulaShared added in v0.6.0

func (c Cell) SetFormulaShared(formula string, rows, cols uint32) error

SetFormulaShared sets the cell type to formula shared, and the raw formula to the given string. The range is the range of cells that the formula applies to, and is used to conserve disk space.

func (c Cell) SetHyperlink(hl common.Hyperlink)

SetHyperlink sets a hyperlink on a cell.

func (Cell) SetInlineString

func (c Cell) SetInlineString(s string)

SetInlineString adds a string inline instead of in the shared strings table.

func (Cell) SetNumber

func (c Cell) SetNumber(v float64)

SetNumber sets the cell type to number, and the value to the given number

func (Cell) SetNumberWithStyle added in v0.2.0

func (c Cell) SetNumberWithStyle(v float64, f StandardFormat)

SetNumberWithStyle sets a number and applies a standard format to the cell.

func (Cell) SetRichTextString added in v0.2.0

func (c Cell) SetRichTextString() RichText

SetRichTextString sets the cell to rich string mode and returns a struct that can be used to add formatted text to the cell.

func (Cell) SetString

func (c Cell) SetString(s string) int

SetString sets the cell type to string, and the value to the given string, returning an ID from the shared strings table. To reuse a string, call SetStringByID with the ID returned.

func (Cell) SetStringByID

func (c Cell) SetStringByID(id int)

SetStringByID sets the cell type to string, and the value a string in the shared strings table.

func (Cell) SetStyle

func (c Cell) SetStyle(cs CellStyle)

SetStyle applies a style to the cell. This style is referenced in the generated XML via CellStyle.Index().

func (Cell) SetStyleIndex added in v0.2.0

func (c Cell) SetStyleIndex(idx uint32)

SetStyleIndex directly sets a style index to the cell. This should only be called with an index retrieved from CellStyle.Index()

func (Cell) SetTime added in v0.2.0

func (c Cell) SetTime(d time.Time)

SetTime sets the cell value to a date. It's stored as the number of days past th sheet epoch. When we support v5 strict, we can store an ISO 8601 date string directly, however that's not allowed with v5 transitional (even though it works in Excel).

func (Cell) X

func (c Cell) X() *sml.CT_Cell

X returns the inner wrapped XML type.

type CellMarker added in v0.2.0

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

CellMarker represents a cell position

func (CellMarker) Col added in v0.2.0

func (c CellMarker) Col() int32

Col returns the column of the cell marker.

func (CellMarker) ColOffset added in v0.2.0

func (c CellMarker) ColOffset() measurement.Distance

ColOffset returns the offset from the row cell.

func (CellMarker) Row added in v0.2.0

func (c CellMarker) Row() int32

Row returns the row of the cell marker.

func (CellMarker) RowOffset added in v0.2.0

func (c CellMarker) RowOffset() measurement.Distance

RowOffset returns the offset from the row cell.

func (CellMarker) SetCol added in v0.2.0

func (c CellMarker) SetCol(col int32)

SetCol set the column of the cell marker.

func (CellMarker) SetColOffset added in v0.2.0

func (c CellMarker) SetColOffset(m measurement.Distance)

SetColOffset sets a column offset in absolute distance.

func (CellMarker) SetRow added in v0.2.0

func (c CellMarker) SetRow(row int32)

SetRow set the row of the cell marker.

func (CellMarker) SetRowOffset added in v0.2.0

func (c CellMarker) SetRowOffset(m measurement.Distance)

SetRowOffset sets a column offset in absolute distance.

func (CellMarker) X added in v0.2.0

func (c CellMarker) X() *sd.CT_Marker

X returns the inner wrapped XML type.

type CellStyle

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

CellStyle is a formatting style for a cell. CellStyles are spreadsheet global and can be applied to cells across sheets.

func (CellStyle) ClearBorder added in v0.2.0

func (cs CellStyle) ClearBorder()

ClearBorder clears any border configuration from the cell style.

func (CellStyle) ClearFill added in v0.2.0

func (cs CellStyle) ClearFill()

ClearFill clears any fill configuration from the cell style.

func (CellStyle) ClearFont

func (cs CellStyle) ClearFont()

ClearFont clears any font configuration from the cell style.

func (CellStyle) ClearNumberFormat added in v0.2.0

func (cs CellStyle) ClearNumberFormat()

ClearNumberFormat removes any number formatting from the style.

func (CellStyle) HasNumberFormat added in v0.2.0

func (cs CellStyle) HasNumberFormat() bool

HasNumberFormat returns true if the cell style has a number format applied.

func (CellStyle) Index

func (cs CellStyle) Index() uint32

func (CellStyle) NumberFormat added in v0.2.0

func (cs CellStyle) NumberFormat() uint32

NumberFormat returns the number format that the cell style uses, or zero if it is not set.

func (CellStyle) SetBorder added in v0.2.0

func (cs CellStyle) SetBorder(b Border)

SetBorder applies a border to a cell style. The border is referenced by its index so modifying the border afterward will affect all styles that reference it.

func (CellStyle) SetFill

func (cs CellStyle) SetFill(f Fill)

SetFill applies a fill to a cell style. The fill is referenced by its index so modifying the fill afterward will affect all styles that reference it.

func (CellStyle) SetFont

func (cs CellStyle) SetFont(f Font)

SetFont applies a font to a cell style. The font is referenced by its index so modifying the font afterward will affect all styles that reference it.

func (CellStyle) SetHorizontalAlignment

func (cs CellStyle) SetHorizontalAlignment(a sml.ST_HorizontalAlignment)

SetHorizontalAlignment sets the horizontal alignment of a cell style.

func (CellStyle) SetNumberFormat added in v0.2.0

func (cs CellStyle) SetNumberFormat(s string)

func (CellStyle) SetNumberFormatStandard added in v0.2.0

func (cs CellStyle) SetNumberFormatStandard(s StandardFormat)

SetNumberFormatStandard sets the format based off of the ECMA 376 standard formats. These formats are standardized and don't need to be defined in the styles.

func (CellStyle) SetShrinkToFit

func (cs CellStyle) SetShrinkToFit(b bool)

func (CellStyle) SetVerticalAlignment

func (cs CellStyle) SetVerticalAlignment(a sml.ST_VerticalAlignment)

SetVerticalAlignment sets the vertical alignment of a cell style.

func (CellStyle) SetWrapped

func (cs CellStyle) SetWrapped(b bool)

SetWrapped configures the cell to wrap text.

func (CellStyle) Wrapped

func (cs CellStyle) Wrapped() bool

Wrapped returns true if the cell will wrap text.

type ColorScale added in v0.2.0

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

ColorScale colors a cell background based off of the cell value.

func (ColorScale) AddFormatValue added in v0.2.0

func (c ColorScale) AddFormatValue(t sml.ST_CfvoType, val string)

AddFormatValue adds a format value to be used to determine the cell background.

func (ColorScale) AddGradientStop added in v0.2.0

func (c ColorScale) AddGradientStop(color color.Color)

AddGradientStop adds a color gradient stop.

func (ColorScale) X added in v0.2.0

func (c ColorScale) X() *sml.CT_ColorScale

X returns the inner wrapped XML type.

type Column added in v0.2.0

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

Column represents a column within a sheet. It's only used for formatting purposes, so it's possible to construct a sheet without configuring columns.

func (Column) SetHidden added in v0.2.0

func (c Column) SetHidden(b bool)

SetHidden controls the visibility of a column.

func (Column) SetStyle added in v0.2.0

func (c Column) SetStyle(cs CellStyle)

SetStyle sets the cell style for an entire column.

func (Column) SetWidth added in v0.2.0

func (c Column) SetWidth(w measurement.Distance)

SetWidth controls the width of a column.

func (Column) X added in v0.2.0

func (c Column) X() *sml.CT_Col

X returns the inner wrapped XML type.

type Comment added in v0.2.0

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

Comment is a single comment within a sheet.

func (Comment) Author added in v0.2.0

func (c Comment) Author() string

Author returns the author of the comment

func (Comment) CellReference added in v0.2.0

func (c Comment) CellReference() string

CellReference returns the cell reference within a sheet that a comment refers to (e.g. "A1")

func (Comment) SetAuthor added in v0.2.0

func (c Comment) SetAuthor(author string)

SetAuthor sets the author of the comment. If the comment body contains the author's name (as is the case with Excel and Comments.AddCommentWithStyle, it will not be changed). This method only changes the metadata author of the comment.

func (Comment) SetCellReference added in v0.2.0

func (c Comment) SetCellReference(cellRef string)

SetCellReference sets the cell reference within a sheet that a comment refers to (e.g. "A1")

func (Comment) X added in v0.2.0

func (c Comment) X() *sml.CT_Comment

X returns the inner wrapped XML type.

type Comments added in v0.2.0

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

Comments is the container for comments for a single sheet.

func MakeComments added in v0.2.0

func MakeComments(w *Workbook, x *sml.Comments) Comments

MakeComments constructs a new Comments wrapper.

func (Comments) AddComment added in v0.2.0

func (c Comments) AddComment(cellRef string, author string) RichText

AddComment adds a new comment and returns a RichText which will contain the styled comment text.

func (Comments) AddCommentWithStyle added in v0.2.0

func (c Comments) AddCommentWithStyle(cellRef string, author string, comment string) error

AddCommentWithStyle adds a new comment styled in a default way

func (Comments) Comments added in v0.2.0

func (c Comments) Comments() []Comment

Comments returns the list of comments for this sheet

func (Comments) X added in v0.2.0

func (c Comments) X() *sml.Comments

X returns the inner wrapped XML type.

type Comparer added in v0.4.0

type Comparer struct {
	Order SortOrder
}

Comparer is used to compare rows based off a column and cells based off of their value.

func (Comparer) LessCells added in v0.4.0

func (c Comparer) LessCells(lhs, rhs Cell) bool

LessCells returns true if the lhs value is less than the rhs value. If the cells contain numeric values, their value interpreted as a floating point is compared. Otherwise their string contents are compared.

func (Comparer) LessRows added in v0.4.0

func (c Comparer) LessRows(column string, lhs, rhs Row) bool

LessRows compares two rows based off of a column. If the column doesn't exist in one row, that row is 'less'.

type ConditionalFormatting added in v0.2.0

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

ConditionalFormatting controls the formatting styles and rules for a range of cells with the same conditional formatting.

func (ConditionalFormatting) AddRule added in v0.2.0

AddRule adds and returns a new rule that can be configured.

func (ConditionalFormatting) X added in v0.2.0

X returns the inner wrapped XML type.

type ConditionalFormattingRule added in v0.2.0

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

func (ConditionalFormattingRule) InitializeDefaults added in v0.2.0

func (c ConditionalFormattingRule) InitializeDefaults()

func (ConditionalFormattingRule) Operator added in v0.2.0

Operator returns the operator for the rule

func (ConditionalFormattingRule) Priority added in v0.2.0

func (c ConditionalFormattingRule) Priority() int32

Priority returns the rule priority

func (ConditionalFormattingRule) SetColorScale added in v0.2.0

func (c ConditionalFormattingRule) SetColorScale() ColorScale

SetColorScale configures the rule as a color scale, removing existing configuration.

func (ConditionalFormattingRule) SetConditionValue added in v0.2.0

func (c ConditionalFormattingRule) SetConditionValue(v string)

SetConditionValue sets the condition value to be used for style applicaton.

func (ConditionalFormattingRule) SetDataBar added in v0.2.0

func (c ConditionalFormattingRule) SetDataBar() DataBarScale

SetDataBar configures the rule as a data bar, removing existing configuration.

func (ConditionalFormattingRule) SetIcons added in v0.2.0

func (c ConditionalFormattingRule) SetIcons() IconScale

SetIcons configures the rule as an icon scale, removing existing configuration.

func (ConditionalFormattingRule) SetOperator added in v0.2.0

SetOperator sets the operator for the rule.

func (ConditionalFormattingRule) SetPriority added in v0.2.0

func (c ConditionalFormattingRule) SetPriority(p int32)

SetPriority sets the rule priority

func (ConditionalFormattingRule) SetStyle added in v0.2.0

SetStyle sets the style to be used for conditional rules

func (ConditionalFormattingRule) SetType added in v0.2.0

SetType sets the type of the rule.

func (ConditionalFormattingRule) Type added in v0.2.0

Type returns the type of the rule

func (ConditionalFormattingRule) X added in v0.2.0

X returns the inner wrapped XML type.

type DVCompareOp added in v0.2.0

type DVCompareOp byte

DVCompareOp is a comparison operator for a data validation rule.

type DVCompareType added in v0.2.0

type DVCompareType byte

DVCompareType is a comparison type for a data validation rule. This restricts the input format of the cell.

type DataBarScale added in v0.2.0

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

DataBarScale is a colored scale that fills the cell with a background gradeint depending on the value.

func (DataBarScale) AddFormatValue added in v0.2.0

func (d DataBarScale) AddFormatValue(t sml.ST_CfvoType, val string)

AddFormatValue adds a format value (databars require two).

func (DataBarScale) SetColor added in v0.2.0

func (d DataBarScale) SetColor(c color.Color)

SetColor sets teh color of the databar.

func (DataBarScale) SetMaxLength added in v0.2.0

func (d DataBarScale) SetMaxLength(l uint32)

SetMaxLength sets the maximum bar length in percent.

func (DataBarScale) SetMinLength added in v0.2.0

func (d DataBarScale) SetMinLength(l uint32)

SetMinLength sets the minimum bar length in percent.

func (DataBarScale) SetShowValue added in v0.2.0

func (d DataBarScale) SetShowValue(b bool)

SetShowValue controls if the cell value is displayed.

func (DataBarScale) X added in v0.2.0

func (d DataBarScale) X() *sml.CT_DataBar

X returns the inner wrapped XML type.

type DataValidation added in v0.2.0

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

DataValidation controls cell validation

func (DataValidation) SetAllowBlank added in v0.2.0

func (d DataValidation) SetAllowBlank(b bool)

SetAllowBlank controls if blank values are accepted.

func (DataValidation) SetComparison added in v0.2.0

func (DataValidation) SetList added in v0.2.0

func (d DataValidation) SetList() DataValidationList

func (DataValidation) SetRange added in v0.2.0

func (d DataValidation) SetRange(cellRange string)

SetRange sets the cell or range of cells that the validation should apply to. It can be a single cell (e.g. "A1") or a range of cells (e.g. "A1:B5")

func (DataValidation) X added in v0.2.0

X returns the inner wrapped XML type.

type DataValidationCompare added in v0.2.0

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

DataValidationCompare is a view on a data validation rule that is oriented towards value comparisons.

func (DataValidationCompare) SetValue added in v0.2.0

func (d DataValidationCompare) SetValue(v string)

SetValue sets the first value to be used in the comparison. For comparisons that need only one value, this is the only value used. For comparisons like 'between' that require two values, SetValue2 must also be used.

func (DataValidationCompare) SetValue2 added in v0.2.0

func (d DataValidationCompare) SetValue2(v string)

type DataValidationList added in v0.2.0

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

DataValidationList is just a view on a DataValidation configured as a list. It presents a drop-down combo box for spreadsheet users to select values. The contents of the dropdown can either pull from a rang eof cells (SetRange) or specified directly (SetValues).

func (DataValidationList) SetRange added in v0.2.0

func (d DataValidationList) SetRange(cellRange string)

SetRange sets the range that contains the possible values. This is incompatible with SetValues.

func (DataValidationList) SetValues added in v0.2.0

func (d DataValidationList) SetValues(values []string)

SetValues sets the possible values. This is incompatible with SetRange.

type DefinedName added in v0.2.0

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

DefinedName is a named range, formula, etc.

func (DefinedName) Content added in v0.2.0

func (d DefinedName) Content() string

Content returns the content of the defined range (the range in most cases)/

func (DefinedName) Name added in v0.2.0

func (d DefinedName) Name() string

Name returns the name of the defined name.

func (DefinedName) SetContent added in v0.2.0

func (d DefinedName) SetContent(s string)

SetContent sets the defined name content.

func (DefinedName) SetHidden added in v0.2.0

func (d DefinedName) SetHidden(b bool)

SetHidden marks the defined name as hidden.

func (DefinedName) SetLocalSheetID added in v0.2.0

func (d DefinedName) SetLocalSheetID(id uint32)

SetHidden marks the defined name as hidden.

func (DefinedName) X added in v0.2.0

X returns the inner wrapped XML type.

type DifferentialStyle added in v0.2.0

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

func (DifferentialStyle) Fill added in v0.2.0

func (d DifferentialStyle) Fill() Fill

func (DifferentialStyle) Index added in v0.2.0

func (d DifferentialStyle) Index() uint32

Index returns the index of the differential style.

func (DifferentialStyle) X added in v0.2.0

func (d DifferentialStyle) X() *sml.CT_Dxf

X returns the inner wrapped XML type.

type Drawing added in v0.2.0

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

Drawing is a drawing overlay on a sheet. Only a single drawing is allowed per sheet, so to display multiple charts and images on a single sheet, they must be added to the same drawing.

func (Drawing) AddChart added in v0.2.0

func (d Drawing) AddChart(at AnchorType) (chart.Chart, Anchor)

AddChart adds an chart to a drawing, returning the chart and an anchor that can be used to position the chart within the sheet.

func (Drawing) AddImage added in v0.2.0

func (d Drawing) AddImage(img common.ImageRef, at AnchorType) Anchor

AddImage adds an image with a paricular anchor type, returning an anchor to allow adusting the image size/position.

func (Drawing) X added in v0.2.0

func (d Drawing) X() *sd.WsDr

X returns the inner wrapped XML type.

type Fill

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

func (Fill) Index

func (f Fill) Index() uint32

func (Fill) SetPatternFill added in v0.2.0

func (f Fill) SetPatternFill() PatternFill

type Fills

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

func NewFills

func NewFills() Fills

func (Fills) AddFill added in v0.2.0

func (f Fills) AddFill() Fill

func (Fills) X

func (f Fills) X() *sml.CT_Fills

type Font

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

Font allows editing fonts within a spreadsheet stylesheet.

func (Font) Index

func (f Font) Index() uint32

func (Font) SetBold

func (f Font) SetBold(b bool)

func (Font) SetColor

func (f Font) SetColor(c color.Color)

func (Font) SetItalic

func (f Font) SetItalic(b bool)

func (Font) SetName

func (f Font) SetName(name string)

func (Font) SetSize

func (f Font) SetSize(size float64)

func (Font) X

func (f Font) X() *sml.CT_Font

X returns the inner wrapped XML type.

type IconScale added in v0.2.0

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

IconScale maps values to icons.

func (IconScale) AddFormatValue added in v0.2.0

func (c IconScale) AddFormatValue(t sml.ST_CfvoType, val string)

AddFormatValue adds a format value to be used in determining which icons to display.

func (IconScale) SetIcons added in v0.2.0

func (c IconScale) SetIcons(t sml.ST_IconSetType)

SetIcons sets the icon set to use for display.

func (IconScale) X added in v0.2.0

func (c IconScale) X() *sml.CT_IconSet

X returns the inner wrapped XML type.

type MergedCell added in v0.2.0

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

func (MergedCell) Cell added in v0.2.0

func (s MergedCell) Cell() Cell

Cell returns the actual cell behind the merged region

func (MergedCell) Reference added in v0.2.0

func (s MergedCell) Reference() string

Reference returns the region of cells that are merged.

func (MergedCell) SetReference added in v0.2.0

func (s MergedCell) SetReference(ref string)

SetReference sets the regin of cells that the merged cell applies to.

func (MergedCell) X added in v0.2.0

func (s MergedCell) X() *sml.CT_MergeCell

X returns the inner wrapped XML type.

type NumberFormat added in v0.2.0

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

NumberFormat is a number formatting string that can be applied to a cell style.

func CreateDefaultNumberFormat added in v0.3.0

func CreateDefaultNumberFormat(id StandardFormat) NumberFormat

func (NumberFormat) GetFormat added in v0.3.0

func (n NumberFormat) GetFormat() string

GetFormat sets the number format code.

func (NumberFormat) ID added in v0.2.0

func (n NumberFormat) ID() uint32

ID returns the number format ID. This is not an index as there are some predefined number formats which can be used in cell styles and don't need a corresponding NumberFormat.

func (NumberFormat) SetFormat added in v0.3.0

func (n NumberFormat) SetFormat(f string)

SetFormat sets the number format code.

func (NumberFormat) X added in v0.2.0

func (n NumberFormat) X() *sml.CT_NumFmt

X returns the inner wrapped XML type.

type OneCellAnchor added in v0.2.0

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

OneCellAnchor is anchored to a top-left cell with a fixed with/height in distance.

func (OneCellAnchor) BottomRight added in v0.2.0

func (o OneCellAnchor) BottomRight() CellMarker

BottomRight is a no-op.

func (OneCellAnchor) MoveTo added in v0.2.0

func (o OneCellAnchor) MoveTo(col, row int32)

MoveTo moves the top-left of the anchored object.

func (OneCellAnchor) SetColOffset added in v0.2.0

func (o OneCellAnchor) SetColOffset(m measurement.Distance)

SetColOffset sets the column offset of the top-left anchor.

func (OneCellAnchor) SetHeight added in v0.2.0

func (o OneCellAnchor) SetHeight(h measurement.Distance)

SetHeight sets the height of the anchored object.

func (OneCellAnchor) SetHeightCells added in v0.2.0

func (o OneCellAnchor) SetHeightCells(int32)

SetHeightCells is a no-op.

func (OneCellAnchor) SetRowOffset added in v0.2.0

func (o OneCellAnchor) SetRowOffset(m measurement.Distance)

SetRowOffset sets the row offset of the top-left anchor.

func (OneCellAnchor) SetWidth added in v0.2.0

func (o OneCellAnchor) SetWidth(w measurement.Distance)

SetWidth sets the width of the anchored object.

func (OneCellAnchor) SetWidthCells added in v0.2.0

func (o OneCellAnchor) SetWidthCells(int32)

SetWidthCells is a no-op.

func (OneCellAnchor) TopLeft added in v0.2.0

func (o OneCellAnchor) TopLeft() CellMarker

TopLeft returns the top-left corner of the anchored object.

func (OneCellAnchor) Type added in v0.2.0

func (o OneCellAnchor) Type() AnchorType

Type returns the type of anchor

type PatternFill

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

func NewPatternFill

func NewPatternFill(fills *sml.CT_Fills) PatternFill

func (PatternFill) ClearBgColor

func (f PatternFill) ClearBgColor()

func (PatternFill) ClearFgColor

func (f PatternFill) ClearFgColor()

func (PatternFill) SetBgColor

func (f PatternFill) SetBgColor(c color.Color)

func (PatternFill) SetFgColor

func (f PatternFill) SetFgColor(c color.Color)

SetFgColor sets the *fill* foreground color. As an example, the solid pattern foreground color becomes the background color of the cell when applied.

func (PatternFill) SetPattern

func (f PatternFill) SetPattern(p sml.ST_PatternType)

SetPattern sets the pattern of the fill.

func (PatternFill) X

type RichText added in v0.2.0

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

RichText is a container for the rich text within a cell. It's similar to a paragaraph for a document, except a cell can only contain one rich text item.

func (RichText) AddRun added in v0.2.0

func (r RichText) AddRun() RichTextRun

AddRun adds a new run of text to the cell.

func (RichText) X added in v0.2.0

func (r RichText) X() *sml.CT_Rst

X returns the inner wrapped XML type.

type RichTextRun added in v0.2.0

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

RichTextRun is a segment of text within a cell that is directly formatted.

func (RichTextRun) SetBold added in v0.2.0

func (r RichTextRun) SetBold(b bool)

SetBold causes the text to be displayed in bold.

func (RichTextRun) SetColor added in v0.2.0

func (r RichTextRun) SetColor(c color.Color)

SetColor sets the text color.

func (RichTextRun) SetFont added in v0.2.0

func (r RichTextRun) SetFont(s string)

SetFont sets the font name for a rich text run.

func (RichTextRun) SetItalic added in v0.2.0

func (r RichTextRun) SetItalic(b bool)

SetItalic causes the text to be displayed in italic.

func (RichTextRun) SetSize added in v0.2.0

func (r RichTextRun) SetSize(m measurement.Distance)

SetSize sets the text size for a rich text run.

func (RichTextRun) SetText added in v0.2.0

func (r RichTextRun) SetText(s string)

SetText sets the text to be displayed.

func (RichTextRun) SetUnderline added in v0.2.0

func (r RichTextRun) SetUnderline(u sml.ST_UnderlineValues)

SetUnderline controls if the run is underlined.

func (RichTextRun) X added in v0.2.0

func (r RichTextRun) X() *sml.CT_RElt

X returns the inner wrapped XML type.

type Row

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

Row is a row within a spreadsheet.

func (Row) AddCell

func (r Row) AddCell() Cell

AddCell adds a cell to a spreadsheet.

func (Row) AddNamedCell added in v0.2.0

func (r Row) AddNamedCell(col string) Cell

AddNamedCell adds a new named cell to a row and returns it. You should normally prefer Cell() as it will return the existing cell if the cell already exists, while AddNamedCell will duplicate the cell creating an invaild spreadsheet.

func (Row) Cell added in v0.2.0

func (r Row) Cell(col string) Cell

Cell retrieves or adds a new cell to a row. Col is the column (e.g. 'A', 'B')

func (Row) Cells

func (r Row) Cells() []Cell

Cells returns a slice of cells. The cells can be manipulated, but appending to the slice will have no effect.

func (Row) IsHidden

func (r Row) IsHidden() bool

IsHidden returns whether the row is hidden or not.

func (Row) RowNumber added in v0.2.0

func (r Row) RowNumber() uint32

RowNumber returns the row number (1-N), or zero if it is unset.

func (Row) SetHeight

func (r Row) SetHeight(d measurement.Distance)

SetHeight sets the row height in points.

func (Row) SetHeightAuto

func (r Row) SetHeightAuto()

SetHeightAuto sets the row height to be automatically determined.

func (Row) SetHidden

func (r Row) SetHidden(hidden bool)

SetHidden hides or unhides the row

func (Row) X added in v0.2.0

func (r Row) X() *sml.CT_Row

X returns the inner wrapped XML type.

type SharedStrings

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

SharedStrings is a shared strings table, where string data can be placed outside of the sheet contents and referenced from a sheet.

func NewSharedStrings

func NewSharedStrings() SharedStrings

NewSharedStrings constructs a new Shared Strings table.

func (SharedStrings) AddString

func (s SharedStrings) AddString(v string) int

AddString adds a string to the shared string cache.

func (SharedStrings) GetString

func (s SharedStrings) GetString(id int) (string, error)

GetString retrieves a string from the shared strings table by index.

func (SharedStrings) X

func (s SharedStrings) X() *sml.Sst

X returns the inner wrapped XML type.

type Sheet

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

Sheet is a single sheet within a workbook.

func (Sheet) AddConditionalFormatting added in v0.2.0

func (s Sheet) AddConditionalFormatting(cellRanges []string) ConditionalFormatting

AddConditionalFormatting adds conditional formatting to the sheet.

func (Sheet) AddDataValidation added in v0.2.0

func (s Sheet) AddDataValidation() DataValidation

AddDataValidation adds a data validation rule to a sheet.

func (s Sheet) AddHyperlink(url string) common.Hyperlink

AddHyperlink adds a hyperlink to a sheet. Adding the hyperlink to the sheet and setting it on a cell is more efficient than setting hyperlinks directly on a cell.

func (Sheet) AddMergedCells added in v0.2.0

func (s Sheet) AddMergedCells(fromRef, toRef string) MergedCell

AddMergedCells merges cells within a sheet.

func (Sheet) AddNumberedRow added in v0.2.0

func (s Sheet) AddNumberedRow(rowNum uint32) Row

AddNumberedRow adds a row with a given row number. If you reuse a row number the resulting file will fail validation and fail to open in Office programs. Use Row instead which creates a new row or returns an existing row.

Example
package main

import (
	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()

	// AddNumberedRow adds a row with a given number, the difference between Row
	// and AddNumberedRow is that AddNumberedRow doesn't check for an existing
	// row with the same number, while Row will return an existing row if it exists.
	sheet.AddNumberedRow(5).AddCell().SetNumber(1.23)
}
Output:

func (Sheet) AddRow

func (s Sheet) AddRow() Row

AddRow adds a new row to a sheet. You can mix this with numbered rows, however it will get confusing. You should prefer to use either automatically numbered rows with AddRow or manually numbered rows with Row/AddNumberedRow

Example
package main

import (
	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()

	// AddRow/AddCell add a new unspecified row/cell.  These will be numbered
	// sequentially in the resulting file.
	sheet.AddRow().AddCell().SetNumber(1.23)
}
Output:

func (*Sheet) AddView added in v0.2.0

func (s *Sheet) AddView() SheetView

AddView adds a sheet view.

func (Sheet) Cell added in v0.2.0

func (s Sheet) Cell(cellRef string) Cell

Cell creates or returns a cell given a cell reference of the form 'A10'

Example
package main

import (
	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()

	// Cell creates or returns a cell with a given reference
	sheet.Cell("A1").SetNumber(1.23)
}
Output:

func (Sheet) ClearAutoFilter added in v0.2.0

func (s Sheet) ClearAutoFilter()

ClearAutoFilter removes the autofilters from the sheet.

func (*Sheet) ClearCachedFormulaResults added in v0.2.0

func (s *Sheet) ClearCachedFormulaResults()

ClearCachedFormulaResults clears any computed formula values that are stored in the sheet. This may be required if you modify cells that are used as a formula input to force the formulas to be recomputed the next time the sheet is opened in Excel.

func (*Sheet) ClearProtection added in v0.4.0

func (s *Sheet) ClearProtection()

ClearProtection removes any protections applied to teh sheet.

func (*Sheet) ClearSheetViews added in v0.2.0

func (s *Sheet) ClearSheetViews()

ClearSheetViews clears the list of sheet views. This will clear the results of AddView() or SetFrozen.

func (Sheet) Column added in v0.2.0

func (s Sheet) Column(idx uint32) Column

Column returns or creates a column that with a given index (1-N). Columns can span multiple column indices, this method will return the column that applies to a column index if it exists or create a new column that only applies to the index passed in otherwise.

func (Sheet) Comments added in v0.2.0

func (s Sheet) Comments() Comments

Comments returns the comments for a sheet.

func (Sheet) Extents added in v0.2.0

func (s Sheet) Extents() string

Extents returns the sheet extents in the form "A1:B15". This requires scanning the entire sheet.

func (Sheet) ExtentsIndex added in v0.3.0

func (s Sheet) ExtentsIndex() (string, uint32, string, uint32)

func (*Sheet) FormulaContext added in v0.3.0

func (s *Sheet) FormulaContext() formula.Context

FormulaContext returns a formula evaluation context that can be used to evaluate formaulas.

func (*Sheet) InitialView added in v0.2.0

func (s *Sheet) InitialView() SheetView

InitialView returns the first defined sheet view. If there are no views, one is created and returned.

func (Sheet) IsValid added in v0.4.0

func (s Sheet) IsValid() bool

func (Sheet) MergedCells added in v0.2.0

func (s Sheet) MergedCells() []MergedCell

MergedCells returns the merged cell regions within the sheet.

func (Sheet) Name

func (s Sheet) Name() string

Name returns the sheet name

Example
package main

import (
	"fmt"

	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()
	sheet.SetName("Sheet 1")
	fmt.Println(sheet.Name())

}
Output:

Sheet 1

func (*Sheet) Protection added in v0.4.0

func (s *Sheet) Protection() SheetProtection

Protection controls the protection on an individual sheet.

func (Sheet) RangeReference added in v0.2.0

func (s Sheet) RangeReference(n string) string

RangeReference converts a range reference of the form 'A1:A5' to 'Sheet 1'!$A$1:$A$5 . Renaming a sheet after calculating a range reference will invalidate the reference.

func (*Sheet) RecalculateFormulas added in v0.3.0

func (s *Sheet) RecalculateFormulas()

RecalculateFormulas re-computes any computed formula values that are stored in the sheet. As gooxml formula support is still new and not all functins are supported, if formula execution fails either due to a parse error or missing function, or erorr in the result (even if expected) the cached value will be left empty allowing Excel to recompute it on load.

func (Sheet) RemoveMergedCell added in v0.2.0

func (s Sheet) RemoveMergedCell(mc MergedCell)

RemoveMergedCell removes merging from a cell range within a sheet. The cells that made up the merged cell remain, but are no lon merged.

func (Sheet) Row added in v0.2.0

func (s Sheet) Row(rowNum uint32) Row

Row will return a row with a given row number, creating a new row if necessary.

Example
package main

import (
	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	sheet := wb.AddSheet()

	// Row/Cell create or returns a cell with a given reference
	sheet.Row(1).Cell("A").SetNumber(1.23)
}
Output:

func (Sheet) Rows

func (s Sheet) Rows() []Row

Rows returns all of the rows in a sheet.

func (Sheet) SetAutoFilter added in v0.2.0

func (s Sheet) SetAutoFilter(rangeRef string)

SetAutoFilter creates autofilters on the sheet. These are the automatic filters that are common for a header row. The RangeRef should be of the form "A1:C5" and cover the entire range of cells to be filtered, not just the header. SetAutoFilter replaces any existing auto filter on the sheet.

func (Sheet) SetBorder added in v0.2.0

func (s Sheet) SetBorder(cellRange string, border Border) error

SetBorder is a helper function for creating borders across multiple cells. In the OOXML spreadsheet format, a border applies to a single cell. To draw a 'boxed' border around multiple cells, you need to apply different styles to the cells on the top,left,right,bottom and four corners. This function breaks apart a single border into its components and applies it to cells as needed to give the effect of a border applying to multiple cells.

func (Sheet) SetDrawing added in v0.2.0

func (s Sheet) SetDrawing(d Drawing)

SetDrawing sets the worksheet drawing. A worksheet can have a reference to a single drawing, but the drawing can have many charts.

func (*Sheet) SetFrozen added in v0.2.0

func (s *Sheet) SetFrozen(firstRow, firstCol bool)

SetFrozen removes any existing sheet views and creates a new single view with either the first row, first column or both frozen.

func (Sheet) SetName

func (s Sheet) SetName(name string)

SetName sets the sheet name.

func (*Sheet) SheetViews added in v0.2.0

func (s *Sheet) SheetViews() []SheetView

SheetViews returns the sheet views defined. This is where splits and frozen rows/cols are configured. Multiple sheet views are allowed, but I'm not aware of there being a use for more than a single sheet view.

func (*Sheet) Sort added in v0.4.0

func (s *Sheet) Sort(column string, firstRow uint32, order SortOrder)

Sort sorts all of the rows within a sheet by the contents of a column. As the file format doesn't suppot indicating that a column should be sorted by the viewing/editing program, we actually need to reorder rows and change cell references during a sort. If the sheet contains formulas, you should call RecalculateFormulas() prior to sorting. The column is in the form "C" and specifies the column to sort by. The firstRow is a 1-based index and specifies the firstRow to include in the sort, allowing skipping over a header row.

func (Sheet) Validate

func (s Sheet) Validate() error

Validate validates the sheet, returning an error if it is found to be invalid.

func (Sheet) ValidateWithPath

func (s Sheet) ValidateWithPath(path string) error

ValidateWithPath validates the sheet passing path informaton for a better error message

func (Sheet) X added in v0.2.0

func (s Sheet) X() *sml.Worksheet

X returns the inner wrapped XML type.

type SheetProtection added in v0.4.0

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

func (SheetProtection) IsObjectLocked added in v0.4.0

func (p SheetProtection) IsObjectLocked() bool

IsSheetLocked returns whether the sheet objects are locked.

func (SheetProtection) IsSheetLocked added in v0.4.0

func (p SheetProtection) IsSheetLocked() bool

IsSheetLocked returns whether the sheet is locked.

func (SheetProtection) LockObject added in v0.4.0

func (p SheetProtection) LockObject(b bool)

LockObject controls the locking of the sheet objects.

func (SheetProtection) LockSheet added in v0.4.0

func (p SheetProtection) LockSheet(b bool)

LockSheet controls the locking of the sheet.

func (SheetProtection) PasswordHash added in v0.4.0

func (p SheetProtection) PasswordHash() string

PasswordHash returns the hash of the workbook password.

func (SheetProtection) SetPassword added in v0.4.0

func (p SheetProtection) SetPassword(pw string)

SetPassword sets the password hash to a hash of the input password.

func (SheetProtection) SetPasswordHash added in v0.4.0

func (p SheetProtection) SetPasswordHash(pwHash string)

SetPasswordHash sets the password hash to the input.

func (SheetProtection) X added in v0.4.0

X returns the inner wrapped XML type.

type SheetView added in v0.2.0

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

SheetView is a view of a sheet. There is typically one per sheet, though more are supported.

func (SheetView) SetShowRuler added in v0.2.0

func (s SheetView) SetShowRuler(b bool)

SetShowRuler controls the visibility of the ruler

func (SheetView) SetState added in v0.2.0

func (s SheetView) SetState(st sml.ST_PaneState)

SetState sets the sheet view state (frozen/split/frozen-split)

func (SheetView) SetTopLeft added in v0.2.0

func (s SheetView) SetTopLeft(cellRef string)

SetTopLeft sets the top left visible cell after the split.

func (SheetView) SetXSplit added in v0.2.0

func (s SheetView) SetXSplit(v float64)

SetXSplit sets the column split point

func (SheetView) SetYSplit added in v0.2.0

func (s SheetView) SetYSplit(v float64)

SetYSplit sets the row split point

func (SheetView) SetZoom added in v0.2.0

func (s SheetView) SetZoom(pct uint32)

SetZoom controls the zoom level of the sheet and is measured in percent. The default value is 100.

func (SheetView) X added in v0.2.0

func (s SheetView) X() *sml.CT_SheetView

X returns the inner wrapped XML type.

type SortOrder added in v0.4.0

type SortOrder byte

SortOrder is a column sort order.

const (
	SortOrderAscending SortOrder = iota
	SortOrderDescending
)

SortOrder constants

func (SortOrder) String added in v0.4.0

func (i SortOrder) String() string

type StandardFormat added in v0.2.0

type StandardFormat uint32

StandardFormat is a standard ECMA 376 number format.

const (
	StandardFormatGeneral     StandardFormat = 0  // General
	StandardFormat0           StandardFormat = 0  // General
	StandardFormatWholeNumber StandardFormat = 1  // 0
	StandardFormat1           StandardFormat = 1  // 0
	StandardFormat2           StandardFormat = 2  // 0.00
	StandardFormat3           StandardFormat = 3  // #,##0
	StandardFormat4           StandardFormat = 4  // #,##0.00
	StandardFormatPercent     StandardFormat = 9  // 0%
	StandardFormat9           StandardFormat = 9  // 0%
	StandardFormat10          StandardFormat = 10 // 0.00%
	StandardFormat11          StandardFormat = 11 // 0.00E+00
	StandardFormat12          StandardFormat = 12 // # ?/?
	StandardFormat13          StandardFormat = 13 // # ??/??
	StandardFormatDate        StandardFormat = 14 // m/d/yy
	StandardFormat14          StandardFormat = 14 // m/d/yy
	StandardFormat15          StandardFormat = 15 // d-mmm-yy
	StandardFormat16          StandardFormat = 16 // d-mmm
	StandardFormat17          StandardFormat = 17 // mmm-yy
	StandardFormat18          StandardFormat = 18 // h:mm AM/PM
	StandardFormatTime        StandardFormat = 19 // h:mm:ss AM/PM
	StandardFormat19          StandardFormat = 19 // h:mm:ss AM/PM
	StandardFormat20          StandardFormat = 20 // h:mm
	StandardFormat21          StandardFormat = 21 // h:mm:ss
	StandardFormatDateTime    StandardFormat = 22 // m/d/yy h:mm
	StandardFormat22          StandardFormat = 22 // m/d/yy h:mm
	StandardFormat37          StandardFormat = 37 // #,##0 ;(#,##0)
	StandardFormat38          StandardFormat = 38 // #,##0 ;[Red](#,##0)
	StandardFormat39          StandardFormat = 39 // #,##0.00;(#,##0.00)
	StandardFormat40          StandardFormat = 40 // #,##0.00;[Red](#,##0.00)
	StandardFormat45          StandardFormat = 45 // mm:ss
	StandardFormat46          StandardFormat = 46 // [h]:mm:ss
	StandardFormat47          StandardFormat = 47 // mm:ss.0
	StandardFormat48          StandardFormat = 48 // ##0.0E+0
	StandardFormat49          StandardFormat = 49 // @
)

StandardFormat constants, extracted from ECMA-376 Part 1 Section 18.8.30

func (StandardFormat) String added in v0.4.0

func (i StandardFormat) String() string

type StyleSheet

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

StyleSheet is a document style sheet.

func NewStyleSheet

func NewStyleSheet(wb *Workbook) StyleSheet

NewStyleSheet constructs a new default stylesheet.

func (StyleSheet) AddBorder added in v0.2.0

func (s StyleSheet) AddBorder() Border

AddBorder creates a new empty border that can be applied to a cell style.

func (StyleSheet) AddCellStyle

func (s StyleSheet) AddCellStyle() CellStyle

AddCellStyle adds a new empty cell style to the stylesheet.

func (StyleSheet) AddDifferentialStyle added in v0.2.0

func (s StyleSheet) AddDifferentialStyle() DifferentialStyle

AddDifferentialStyle adds a new empty differential cell style to the stylesheet.

func (StyleSheet) AddFont

func (s StyleSheet) AddFont() Font

AddFont adds a new empty font to the stylesheet.

func (StyleSheet) AddNumberFormat added in v0.2.0

func (s StyleSheet) AddNumberFormat() NumberFormat

AddNumberFormat adds a new blank number format to the stylesheet.

func (StyleSheet) CellStyles added in v0.2.0

func (s StyleSheet) CellStyles() []CellStyle

CellStyles returns the list of defined cell styles

func (StyleSheet) Fills

func (s StyleSheet) Fills() Fills

Fills returns a Fills object that can be used to add/create/edit fills.

func (StyleSheet) Fonts

func (s StyleSheet) Fonts() []Font

Fonts returns the list of fonts defined in the stylesheet.

func (StyleSheet) GetCellStyle added in v0.3.0

func (s StyleSheet) GetCellStyle(id uint32) CellStyle

func (StyleSheet) GetNumberFormat added in v0.3.0

func (s StyleSheet) GetNumberFormat(id uint32) NumberFormat

func (StyleSheet) GetOrCreateStandardNumberFormat added in v0.2.0

func (s StyleSheet) GetOrCreateStandardNumberFormat(f StandardFormat) CellStyle

GetOrCreateStandardNumberFormat gets or creates a cell style with a given standard format. This should only be used when you want to perform number/date/time formatting only. Manipulating the style returned will cause all cells using style returned from this for a given format to be formatted.

func (StyleSheet) RemoveFont

func (s StyleSheet) RemoveFont(f Font) error

RemoveFont removes a font from the style sheet. It *does not* update styles that refer to this font.

func (StyleSheet) X

func (s StyleSheet) X() *sml.StyleSheet

X returns the inner XML entity for a stylesheet.

type Table added in v0.3.0

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

func (Table) Name added in v0.3.0

func (t Table) Name() string

Name returns the name of the table

func (Table) Reference added in v0.3.0

func (t Table) Reference() string

Reference returns the table reference (the cells within the table)

func (Table) X added in v0.3.0

func (t Table) X() *sml.Table

X returns the inner wrapped XML type.

type TwoCellAnchor added in v0.2.0

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

TwoCellAnchor is an anchor that is attached to a top-left cell with a fixed width/height in cells.

func (TwoCellAnchor) BottomRight added in v0.2.0

func (t TwoCellAnchor) BottomRight() CellMarker

BottomRight returns the CellMaker for the bottom right corner of the anchor.

func (TwoCellAnchor) MoveTo added in v0.2.0

func (t TwoCellAnchor) MoveTo(col, row int32)

MoveTo repositions the anchor without changing the objects size.

func (TwoCellAnchor) SetColOffset added in v0.2.0

func (t TwoCellAnchor) SetColOffset(m measurement.Distance)

SetColOffset sets the column offset of the two cell anchor.

func (TwoCellAnchor) SetHeight added in v0.2.0

func (t TwoCellAnchor) SetHeight(h measurement.Distance)

SetHeight is a nop-op.

func (TwoCellAnchor) SetHeightCells added in v0.2.0

func (t TwoCellAnchor) SetHeightCells(h int32)

SetHeightCells sets the height the anchored object by moving the bottom. It is not compatible with SetHeight.

func (TwoCellAnchor) SetRowOffset added in v0.2.0

func (t TwoCellAnchor) SetRowOffset(m measurement.Distance)

SetRowOffset sets the row offset of the two cell anchor

func (TwoCellAnchor) SetWidth added in v0.2.0

func (t TwoCellAnchor) SetWidth(w measurement.Distance)

SetWidth is a no-op.

func (TwoCellAnchor) SetWidthCells added in v0.2.0

func (t TwoCellAnchor) SetWidthCells(w int32)

SetWidthCells sets the height the anchored object by moving the right hand side. It is not compatible with SetWidth.

func (TwoCellAnchor) TopLeft added in v0.2.0

func (t TwoCellAnchor) TopLeft() CellMarker

TopLeft returns the CellMaker for the top left corner of the anchor.

func (TwoCellAnchor) Type added in v0.2.0

func (t TwoCellAnchor) Type() AnchorType

Type returns the type of anchor

type Workbook

type Workbook struct {
	common.DocBase

	StyleSheet    StyleSheet
	SharedStrings SharedStrings
	// contains filtered or unexported fields
}

Workbook is the top level container item for a set of spreadsheets.

func New

func New() *Workbook

New constructs a new workbook.

func Open

func Open(filename string) (*Workbook, error)

Open opens and reads a workbook from a file (.xlsx).

func Read

func Read(r io.ReaderAt, size int64) (*Workbook, error)

Read reads a workbook from an io.Reader(.xlsx).

func (*Workbook) AddDefinedName added in v0.2.0

func (wb *Workbook) AddDefinedName(name, ref string) DefinedName

AddDefinedName adds a name for a cell or range reference that can be used in formulas and charts.

Example
package main

import (
	"fmt"

	"baliance.com/gooxml/spreadsheet"
)

func main() {
	wb := spreadsheet.New()
	defer wb.Close()
	sheet := wb.AddSheet()
	productNames := wb.AddDefinedName("ProductNames", sheet.RangeReference("A2:A6"))
	// now 'ProductNames' can be used in formulas, charts, etc.
	fmt.Printf("%s refers to %s", productNames.Name(), productNames.Content())
}
Output:

ProductNames refers to 'Sheet 1'!$A$2:$A$6

func (*Workbook) AddDrawing added in v0.2.0

func (wb *Workbook) AddDrawing() Drawing

AddDrawing adds a drawing to a workbook. However the drawing is not actually displayed or used until it's set on a sheet.

func (*Workbook) AddImage added in v0.2.0

func (wb *Workbook) AddImage(i common.Image) (common.ImageRef, error)

AddImage adds an image to the workbook package, returning a reference that can be used to add the image to a drawing.

func (*Workbook) AddSheet

func (wb *Workbook) AddSheet() Sheet

AddSheet adds a new sheet with a given name to a workbook.

func (*Workbook) ClearCachedFormulaResults added in v0.2.0

func (wb *Workbook) ClearCachedFormulaResults()

ClearCachedFormulaResults clears any computed formula values that are stored in the sheet. This may be required if you modify cells that are used as a formula input to force the formulas to be recomputed the next time the sheet is opened in Excel.

func (*Workbook) ClearProtection added in v0.4.0

func (wb *Workbook) ClearProtection()

ClearProtection clears all workbook protections.

func (*Workbook) Close added in v0.6.0

func (wb *Workbook) Close() error

Close closes the workbook, removing any temporary files that might have been created when opening a document.

func (*Workbook) DefinedNames added in v0.2.0

func (wb *Workbook) DefinedNames() []DefinedName

DefinedNames returns a slice of all defined names in the workbook.

func (*Workbook) Epoch added in v0.2.0

func (wb *Workbook) Epoch() time.Time

Epoch returns the point at which the dates/times in the workbook are relative to.

func (*Workbook) GetSheet added in v0.4.0

func (wb *Workbook) GetSheet(name string) (Sheet, error)

GetSheet returns a sheet by name, or an error if a sheet by the given name was not found.

func (*Workbook) Protection added in v0.4.0

func (wb *Workbook) Protection() WorkbookProtection

Protection allows control over the workbook protections.

func (*Workbook) RecalculateFormulas added in v0.3.0

func (wb *Workbook) RecalculateFormulas()

RecalculateFormulas re-computes any computed formula values that are stored in the sheet. As gooxml formula support is still new and not all functins are supported, if formula execution fails either due to a parse error or missing function, or erorr in the result (even if expected) the cached value will be left empty allowing Excel to recompute it on load.

func (*Workbook) RemoveDefinedName added in v0.2.0

func (wb *Workbook) RemoveDefinedName(dn DefinedName) error

RemoveDefinedName removes an existing defined name.

func (*Workbook) Save

func (wb *Workbook) Save(w io.Writer) error

Save writes the workbook out to a writer in the zipped xlsx format.

func (*Workbook) SaveToFile

func (wb *Workbook) SaveToFile(path string) error

SaveToFile writes the workbook out to a file.

func (*Workbook) SetActiveSheet added in v0.2.0

func (wb *Workbook) SetActiveSheet(s Sheet)

SetActiveSheet sets the active sheet which will be the tab displayed when the spreadsheet is initially opened.

func (*Workbook) SetActiveSheetIndex added in v0.2.0

func (wb *Workbook) SetActiveSheetIndex(idx uint32)

SetActiveSheetIndex sets the index of the active sheet (0-n) which will be the tab displayed when the spreadsheet is initially opened.

func (Workbook) SheetCount

func (wb Workbook) SheetCount() int

SheetCount returns the number of sheets in the workbook.

func (*Workbook) Sheets

func (wb *Workbook) Sheets() []Sheet

Sheets returns the sheets from the workbook.

func (*Workbook) Tables added in v0.3.0

func (wb *Workbook) Tables() []Table

Tables returns a slice of all defined tables in the workbook.

func (*Workbook) Uses1904Dates added in v0.2.0

func (wb *Workbook) Uses1904Dates() bool

Uses1904Dates returns true if the the workbook uses dates relative to 1 Jan 1904. This is uncommon.

func (*Workbook) Validate

func (wb *Workbook) Validate() error

Validate attempts to validate the structure of a workbook.

func (*Workbook) X

func (wb *Workbook) X() *sml.Workbook

X returns the inner wrapped XML type.

type WorkbookProtection added in v0.4.0

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

func (WorkbookProtection) IsStructureLocked added in v0.4.0

func (p WorkbookProtection) IsStructureLocked() bool

IsStructureLocked returns whether the workbook structure is locked.

func (WorkbookProtection) IsWindowLocked added in v0.4.0

func (p WorkbookProtection) IsWindowLocked() bool

IsWindowLocked returns whether the workbook windows are locked.

func (WorkbookProtection) LockStructure added in v0.4.0

func (p WorkbookProtection) LockStructure(b bool)

LockStructure controls the locking of the workbook structure.

func (WorkbookProtection) LockWindow added in v0.4.0

func (p WorkbookProtection) LockWindow(b bool)

LockWindow controls the locking of the workbook windows.

func (WorkbookProtection) PasswordHash added in v0.4.0

func (p WorkbookProtection) PasswordHash() string

PasswordHash returns the hash of the workbook password.

func (WorkbookProtection) SetPassword added in v0.4.0

func (p WorkbookProtection) SetPassword(pw string)

SetPassword sets the password hash to a hash of the input password.

func (WorkbookProtection) SetPasswordHash added in v0.4.0

func (p WorkbookProtection) SetPasswordHash(pwHash string)

SetPasswordHash sets the password hash to the input.

func (WorkbookProtection) X added in v0.4.0

X returns the inner wrapped XML type.

Directories

Path Synopsis
Package format provides support for parsing and evaluating spreadsheetml/Excel number formats.
Package format provides support for parsing and evaluating spreadsheetml/Excel number formats.
Package formula provides formula parsing and evaluation.
Package formula provides formula parsing and evaluation.

Jump to

Keyboard shortcuts

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