spreadsheet

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSheet

func RegisterSheet(name string, fn SheetFunc)

RegisterSheet ... registers a SheetFunc with the given 'name'. A SheetFunc must be registered before calling 'AddSheet' to add sheets.

Types

type Column

type Column struct {
	FriendlyName string
	FieldName    string
}

Column ... used to describe a column on a sheet if FieldName is empty, the column is considered to be static

type Payload

type Payload struct {
	Static []string
	Items  []interface{}
}

Payload ... used by Update and UpdateSheet to populate a sheet with particular datasets. Static is prepended to every row created by Items. Items should be a slice of objects

func (*Payload) String added in v0.1.2

func (p *Payload) String() (msg string)

type Sheet

type Sheet struct {
	Name    string
	Columns []*Column
	// contains filtered or unexported fields
}

Sheet ... holds a pointer to the underlying xlsx.Sheet, the sheet name, and all of the columns returned by the SheetFunc

func (*Sheet) Update

func (s *Sheet) Update(payload *Payload)

Update ... Enumerates over the provided array, adding a new row for each element and prepending each row with the StaticValues

type SheetFunc

type SheetFunc func() *Sheet

SheetFunc ... used by RegisterSheet to register sheets allow to be used by the AWS report

type Spreadsheet

type Spreadsheet struct {
	Name   string
	Sheets []*Sheet
	// contains filtered or unexported fields
}

Spreadsheet ... holds the desired filename and all sheets created by calling 'AddSheet'

func New

func New(name string) *Spreadsheet

New ... returns a *Spreadsheet, and sets the filename to the provided 'name'

func (*Spreadsheet) AddSheet

func (ss *Spreadsheet) AddSheet(name string) error

AddSheet ... creates a new sheet using the matching SheetFunc given the provided 'name'. Then initializes the sheet by creating the header row and adding the column names

func (*Spreadsheet) Bytes

func (ss *Spreadsheet) Bytes() (*bytes.Reader, error)

Bytes ... creates a bytes.Buffer, saves the underlying xlsx.File to the buffer, then returns the bytes wrapped in a bytes.Reader

func (*Spreadsheet) UpdateSheet

func (ss *Spreadsheet) UpdateSheet(name string, payload *Payload)

UpdateSheet ... finds the sheet matching the given 'name', then calls Update passing the payload provided

Jump to

Keyboard shortcuts

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