spreadsheet

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: 18 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.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Borders

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

func NewBorders

func NewBorders() Borders

func (Borders) X

func (b Borders) X() *sml.CT_Borders

type Cell

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

Cell is a single cell within a sheet.

func (Cell) GetValue

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

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) SetFormulaRaw

func (c Cell) SetFormulaRaw(s string)

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

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) 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) X

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

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) ClearFont

func (cs CellStyle) ClearFont()

func (CellStyle) Index

func (cs CellStyle) Index() uint32

func (CellStyle) SetFill

func (cs CellStyle) SetFill(f Fill)

func (CellStyle) SetFont

func (cs CellStyle) SetFont(f Font)

func (CellStyle) SetHorizontalAlignment

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

SetHorizontalAlignment sets the horizontal alignment of a cell style.

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 Fill

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

func (Fill) Index

func (f Fill) Index() uint32

type Fills

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

func NewFills

func NewFills() Fills

func (Fills) AddPatternFill

func (f Fills) AddPatternFill() PatternFill

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 PatternFill

type PatternFill struct {
	Fill
}

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

func (f PatternFill) X() *sml.CT_Fill

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) Cells

func (r Row) Cells() []Cell

func (Row) IsHidden

func (r Row) IsHidden() bool

IsHidden returns whether the row is hidden or not.

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

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) AddRow

func (s Sheet) AddRow() Row

AddRow adds a new row to a sheet.

func (Sheet) Name

func (s Sheet) Name() string

Name returns the sheet name

func (Sheet) Rows

func (s Sheet) Rows() []Row

Rows returns all of the rows in a sheet.

func (Sheet) SetName

func (s Sheet) SetName(name string)

SetName sets the sheet name.

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

type StyleSheet

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

StyleSheet is a document style sheet.

func NewStyleSheet

func NewStyleSheet() StyleSheet

NewStyleSheet constructs a new default stylesheet.

func (StyleSheet) AddCellStyle

func (s StyleSheet) AddCellStyle() CellStyle

AddCellStyle adds a new empty cell style to the stylesheet.

func (StyleSheet) AddFont

func (s StyleSheet) AddFont() Font

AddFont adds a new empty font to the stylesheet.

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) 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 innter XML entity for a stylesheet.

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) AddSheet

func (wb *Workbook) AddSheet() Sheet

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

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) 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) 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.

Jump to

Keyboard shortcuts

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