HomeUniDoc
...

Package formula

Overview ▾

Package formula provides formula parsing and evaluation. The lexer is implemented with a ragel grammar while the the parser is implemented with goyacc. The entire formula grammar is not implemented and not all functions are supported yet. For compatibility sake, upon failure to parse or execute a formula, unioffice leaves cached formula results blank allowing Excel to compute formulas upon load. This is similar to what most other Excel libraries do which leave all cached results blank instead of attempting to execute formulas.

The unit tests for this package are unique in that we can take advantage of "cached" formula results that Excel/LibreOffice write to the sheet. These are the computed results of a formula in string form. By comparing these values to the value computed by the unioffice evaluation of the formula, adding a new test means just adding a new formula to one of the reference sheets with Excel. During the unit test, we evaluate the formula and compare it to the value that Excel computed. If they're the same, the test passes.

Index ▾

Variables
func LexReader(r io.Reader) chan *node
func RegisterFunction(name string, fn Function)
func RegisterFunctionComplex(name string, fn FunctionComplex)
func SupportedFunctions() []string
type BinOpType
    func (i BinOpType) String() string
type BinaryExpr
    func (b BinaryExpr) Eval(ctx Context, ev Evaluator) Result
    func (b BinaryExpr) Reference(ctx Context, ev Evaluator) Reference
    func (b BinaryExpr) String() string
    func (b BinaryExpr) Update(q *update.UpdateQuery) Expression
type Bool
    func (b Bool) Eval(ctx Context, ev Evaluator) Result
    func (b Bool) Reference(ctx Context, ev Evaluator) Reference
    func (b Bool) String() string
    func (b Bool) Update(q *update.UpdateQuery) Expression
type CellRef
    func (c CellRef) Eval(ctx Context, ev Evaluator) Result
    func (c CellRef) Reference(ctx Context, ev Evaluator) Reference
    func (c CellRef) String() string
    func (c CellRef) Update(q *update.UpdateQuery) Expression
type ConstArrayExpr
    func (c ConstArrayExpr) Eval(ctx Context, ev Evaluator) Result
    func (c ConstArrayExpr) Reference(ctx Context, ev Evaluator) Reference
    func (c ConstArrayExpr) String() string
    func (c ConstArrayExpr) Update(q *update.UpdateQuery) Expression
type Context
type EmptyExpr
    func (e EmptyExpr) Eval(ctx Context, ev Evaluator) Result
    func (e EmptyExpr) Reference(ctx Context, ev Evaluator) Reference
    func (e EmptyExpr) String() string
    func (e EmptyExpr) Update(q *update.UpdateQuery) Expression
type Error
    func (e Error) Eval(ctx Context, ev Evaluator) Result
    func (e Error) Reference(ctx Context, ev Evaluator) Reference
    func (e Error) String() string
    func (e Error) Update(q *update.UpdateQuery) Expression
type ErrorType
type Evaluator
    func NewEvaluator() Evaluator
type Expression
    func NewBinaryExpr(lhs Expression, op BinOpType, rhs Expression) Expression
    func NewBool(v string) Expression
    func NewCellRef(v string) Expression
    func NewConstArrayExpr(data [][]Expression) Expression
    func NewEmptyExpr() Expression
    func NewError(v string) Expression
    func NewFunction(name string, args []Expression) Expression
    func NewHorizontalRange(v string) Expression
    func NewNamedRangeRef(v string) Expression
    func NewNegate(e Expression) Expression
    func NewNumber(v string) Expression
    func NewPrefixExpr(pfx, exp Expression) Expression
    func NewPrefixHorizontalRange(pfx Expression, v string) Expression
    func NewPrefixRangeExpr(pfx, from, to Expression) Expression
    func NewPrefixVerticalRange(pfx Expression, v string) Expression
    func NewRange(from, to Expression) Expression
    func NewSheetPrefixExpr(s string) Expression
    func NewString(v string) Expression
    func NewVerticalRange(v string) Expression
    func Parse(r io.Reader) Expression
    func ParseString(s string) Expression
type Function
    func LookupFunction(name string) Function
type FunctionCall
    func (f FunctionCall) Eval(ctx Context, ev Evaluator) Result
    func (f FunctionCall) Reference(ctx Context, ev Evaluator) Reference
    func (f FunctionCall) String() string
    func (f FunctionCall) Update(q *update.UpdateQuery) Expression
type FunctionComplex
    func LookupFunctionComplex(name string) FunctionComplex
type HorizontalRange
    func (r HorizontalRange) Eval(ctx Context, ev Evaluator) Result
    func (r HorizontalRange) Reference(ctx Context, ev Evaluator) Reference
    func (r HorizontalRange) String() string
    func (r HorizontalRange) Update(q *update.UpdateQuery) Expression
type Lexer
    func NewLexer() *Lexer
    func (l *Lexer) Next() *node
type NamedRangeRef
    func (n NamedRangeRef) Eval(ctx Context, ev Evaluator) Result
    func (n NamedRangeRef) Reference(ctx Context, ev Evaluator) Reference
    func (n NamedRangeRef) String() string
    func (n NamedRangeRef) Update(q *update.UpdateQuery) Expression
type Negate
    func (n Negate) Eval(ctx Context, ev Evaluator) Result
    func (n Negate) Reference(ctx Context, ev Evaluator) Reference
    func (n Negate) String() string
    func (n Negate) Update(q *update.UpdateQuery) Expression
type Number
    func (n Number) Eval(ctx Context, ev Evaluator) Result
    func (n Number) Reference(ctx Context, ev Evaluator) Reference
    func (n Number) String() string
    func (n Number) Update(q *update.UpdateQuery) Expression
type PrefixExpr
    func (p PrefixExpr) Eval(ctx Context, ev Evaluator) Result
    func (p PrefixExpr) Reference(ctx Context, ev Evaluator) Reference
    func (p PrefixExpr) String() string
    func (p PrefixExpr) Update(q *update.UpdateQuery) Expression
type PrefixHorizontalRange
    func (r PrefixHorizontalRange) Eval(ctx Context, ev Evaluator) Result
    func (r PrefixHorizontalRange) Reference(ctx Context, ev Evaluator) Reference
    func (r PrefixHorizontalRange) String() string
    func (r PrefixHorizontalRange) Update(q *update.UpdateQuery) Expression
type PrefixRangeExpr
    func (p PrefixRangeExpr) Eval(ctx Context, ev Evaluator) Result
    func (p PrefixRangeExpr) Reference(ctx Context, ev Evaluator) Reference
    func (r PrefixRangeExpr) String() string
    func (r PrefixRangeExpr) Update(q *update.UpdateQuery) Expression
type PrefixVerticalRange
    func (r PrefixVerticalRange) Eval(ctx Context, ev Evaluator) Result
    func (r PrefixVerticalRange) Reference(ctx Context, ev Evaluator) Reference
    func (r PrefixVerticalRange) String() string
    func (r PrefixVerticalRange) Update(q *update.UpdateQuery) Expression
type Range
    func (r Range) Eval(ctx Context, ev Evaluator) Result
    func (r Range) Reference(ctx Context, ev Evaluator) Reference
    func (r Range) String() string
    func (r Range) Update(q *update.UpdateQuery) Expression
type Reference
    func MakeRangeReference(ref string) Reference
type ReferenceType
    func (i ReferenceType) String() string
type Result
    func Accrintm(args []Result) Result
    func Amordegrc(args []Result) Result
    func Amorlinc(args []Result) Result
    func And(args []Result) Result
    func Arabic(args []Result) Result
    func Atan2(args []Result) Result
    func Average(args []Result) Result
    func Averagea(args []Result) Result
    func Base(args []Result) Result
    func Ceiling(args []Result) Result
    func CeilingMath(args []Result) Result
    func CeilingPrecise(args []Result) Result
    func Cell(ctx Context, ev Evaluator, args []Result) Result
    func Char(args []Result) Result
    func Choose(args []Result) Result
    func Clean(args []Result) Result
    func Code(args []Result) Result
    func Column(args []Result) Result
    func Columns(args []Result) Result
    func Combin(args []Result) Result
    func Combina(args []Result) Result
    func Concat(args []Result) Result
    func Count(args []Result) Result
    func CountBlank(args []Result) Result
    func CountIf(args []Result) Result
    func CountIfs(args []Result) Result
    func Counta(args []Result) Result
    func Coupdaybs(args []Result) Result
    func Coupdays(args []Result) Result
    func Coupdaysnc(args []Result) Result
    func Coupncd(args []Result) Result
    func Coupnum(args []Result) Result
    func Couppcd(args []Result) Result
    func Cumipmt(args []Result) Result
    func Cumprinc(args []Result) Result
    func Date(args []Result) Result
    func DateDif(args []Result) Result
    func DateValue(args []Result) Result
    func Day(args []Result) Result
    func Days(args []Result) Result
    func Db(args []Result) Result
    func Ddb(args []Result) Result
    func Decimal(args []Result) Result
    func Degrees(args []Result) Result
    func Disc(args []Result) Result
    func Dollarde(args []Result) Result
    func Dollarfr(args []Result) Result
    func Duration(args []Result) Result
    func Edate(args []Result) Result
    func Effect(args []Result) Result
    func Eomonth(args []Result) Result
    func Even(args []Result) Result
    func Exact(args []Result) Result
    func Fact(args []Result) Result
    func FactDouble(args []Result) Result
    func False(args []Result) Result
    func Find(args []Result) Result
    func Findb(ctx Context, ev Evaluator, args []Result) Result
    func Floor(args []Result) Result
    func FloorMath(args []Result) Result
    func FloorPrecise(args []Result) Result
    func Fv(args []Result) Result
    func Fvschedule(args []Result) Result
    func GCD(args []Result) Result
    func HLookup(args []Result) Result
    func If(args []Result) Result
    func IfError(args []Result) Result
    func IfNA(args []Result) Result
    func Ifs(args []Result) Result
    func Index(args []Result) Result
    func Indirect(ctx Context, ev Evaluator, args []Result) Result
    func Int(args []Result) Result
    func Intrate(args []Result) Result
    func Ipmt(args []Result) Result
    func Irr(args []Result) Result
    func IsBlank(args []Result) Result
    func IsErr(args []Result) Result
    func IsError(args []Result) Result
    func IsEven(args []Result) Result
    func IsFormula(ctx Context, ev Evaluator, args []Result) Result
    func IsLeapYear(ctx Context, ev Evaluator, args []Result) Result
    func IsLogical(ctx Context, ev Evaluator, args []Result) Result
    func IsNA(args []Result) Result
    func IsNonText(args []Result) Result
    func IsNumber(args []Result) Result
    func IsOdd(args []Result) Result
    func IsRef(ctx Context, ev Evaluator, args []Result) Result
    func IsText(args []Result) Result
    func Ispmt(args []Result) Result
    func LCM(args []Result) Result
    func Large(args []Result) Result
    func Left(args []Result) Result
    func Len(args []Result) Result
    func Log(args []Result) Result
    func Lookup(args []Result) Result
    func Lower(args []Result) Result
    func MDeterm(args []Result) Result
    func MakeArrayResult(arr [][]Result) Result
    func MakeBoolResult(b bool) Result
    func MakeEmptyResult() Result
    func MakeErrorResult(msg string) Result
    func MakeErrorResultType(t ErrorType, msg string) Result
    func MakeListResult(list []Result) Result
    func MakeNumberResult(v float64) Result
    func MakeStringResult(s string) Result
    func Match(args []Result) Result
    func Max(args []Result) Result
    func MaxA(args []Result) Result
    func MaxIfs(args []Result) Result
    func Mduration(args []Result) Result
    func Median(args []Result) Result
    func Mid(args []Result) Result
    func Min(args []Result) Result
    func MinA(args []Result) Result
    func MinIfs(args []Result) Result
    func Minute(args []Result) Result
    func Mirr(args []Result) Result
    func Mod(args []Result) Result
    func Month(args []Result) Result
    func Mround(args []Result) Result
    func Multinomial(args []Result) Result
    func Munit(args []Result) Result
    func NA(args []Result) Result
    func Nominal(args []Result) Result
    func Not(args []Result) Result
    func Now(args []Result) Result
    func Nper(args []Result) Result
    func Npv(args []Result) Result
    func Odd(args []Result) Result
    func Oddlprice(args []Result) Result
    func Oddlyield(args []Result) Result
    func Offset(ctx Context, ev Evaluator, args []Result) Result
    func Or(args []Result) Result
    func Pduration(args []Result) Result
    func Pi(args []Result) Result
    func Pmt(args []Result) Result
    func Power(args []Result) Result
    func Ppmt(args []Result) Result
    func Price(args []Result) Result
    func Pricedisc(args []Result) Result
    func Pricemat(args []Result) Result
    func Product(args []Result) Result
    func Proper(args []Result) Result
    func Pv(args []Result) Result
    func Quotient(args []Result) Result
    func Radians(args []Result) Result
    func Rand(args []Result) Result
    func RandBetween(args []Result) Result
    func Rate(args []Result) Result
    func Received(args []Result) Result
    func Replace(args []Result) Result
    func Rept(args []Result) Result
    func Right(args []Result) Result
    func Roman(args []Result) Result
    func Round(args []Result) Result
    func RoundDown(args []Result) Result
    func RoundUp(args []Result) Result
    func Row(args []Result) Result
    func Rows(args []Result) Result
    func Rri(args []Result) Result
    func Search(args []Result) Result
    func Searchb(ctx Context, ev Evaluator, args []Result) Result
    func SeriesSum(args []Result) Result
    func Sign(args []Result) Result
    func Sln(args []Result) Result
    func Small(args []Result) Result
    func Substitute(args []Result) Result
    func Sum(args []Result) Result
    func SumIf(args []Result) Result
    func SumIfs(args []Result) Result
    func SumProduct(args []Result) Result
    func SumSquares(args []Result) Result
    func Syd(args []Result) Result
    func T(args []Result) Result
    func Tbilleq(args []Result) Result
    func Tbillprice(args []Result) Result
    func Tbillyield(args []Result) Result
    func Text(args []Result) Result
    func TextJoin(args []Result) Result
    func Time(args []Result) Result
    func TimeValue(args []Result) Result
    func Today(args []Result) Result
    func Transpose(args []Result) Result
    func Trim(args []Result) Result
    func True(args []Result) Result
    func Trunc(args []Result) Result
    func Unicode(args []Result) Result
    func Upper(args []Result) Result
    func VLookup(args []Result) Result
    func Value(args []Result) Result
    func Vdb(args []Result) Result
    func Xirr(args []Result) Result
    func Xnpv(args []Result) Result
    func Xor(args []Result) Result
    func Year(ctx Context, ev Evaluator, args []Result) Result
    func YearFrac(args []Result) Result
    func Yield(args []Result) Result
    func Yielddisc(args []Result) Result
    func Yieldmat(args []Result) Result
    func (r Result) AsNumber() Result
    func (r Result) AsString() Result
    func (r Result) ListValues() []Result
    func (r Result) String() string
    func (r Result) Value() string
type ResultType
    func (i ResultType) String() string
type SheetPrefixExpr
    func (s SheetPrefixExpr) Eval(ctx Context, ev Evaluator) Result
    func (s SheetPrefixExpr) Reference(ctx Context, ev Evaluator) Reference
    func (s SheetPrefixExpr) String() string
    func (s SheetPrefixExpr) Update(q *update.UpdateQuery) Expression
type String
    func (s String) Eval(ctx Context, ev Evaluator) Result
    func (s String) Reference(ctx Context, ev Evaluator) Reference
    func (s String) String() string
    func (s String) Update(q *update.UpdateQuery) Expression
type VerticalRange
    func (r VerticalRange) Eval(ctx Context, ev Evaluator) Result
    func (r VerticalRange) Reference(ctx Context, ev Evaluator) Reference
    func (r VerticalRange) String() string
    func (r VerticalRange) Update(q *update.UpdateQuery) Expression

Package files

binaryexpr.go binoptype_string.go bool.go cellref.go columnref.go constarrayexpr.go context.go def_eval.go doc.go emptyexpr.go error.go evaluator.go evcache.go expression.go fndatetime.go fnfinance.go fnindex.go fninformation.go fnlogical.go fnmathtrig.go fnstatistical.go fntext.go functioncall.go grammar.go horizontalrange.go invalidreferencecontext.go lex.go lexer.go namedrangeref.go negate.go nocache.go number.go parser.go prefixexpr.go prefixhorizontalrange.go prefixrangeexpr.go prefixverticalrange.go range.go reference.go referencetype_string.go register.go result.go resulttype_string.go sheetprefixexpr.go string.go verticalrange.go

Variables

InvalidReferenceContext is a Context that can be used when evaluating an invalid reference (e.g. referencing a non-existent sheet). It implements Context safely, but returns error results.

var InvalidReferenceContext = &ivr{}
var ReferenceInvalid = Reference{Type: ReferenceTypeInvalid}

func LexReader

func LexReader(r io.Reader) chan *node

func RegisterFunction

func RegisterFunction(name string, fn Function)

RegisterFunction registers a standard function.

func RegisterFunctionComplex

func RegisterFunctionComplex(name string, fn FunctionComplex)

RegisterFunctionComplex registers a standard function.

func SupportedFunctions

func SupportedFunctions() []string

SupportedFunctions returns a list of supported functions.

type BinOpType

BinOpType is the binary operation operator type

type BinOpType byte

Operator type constants

const (
    BinOpTypeUnknown BinOpType = iota
    BinOpTypePlus
    BinOpTypeMinus
    BinOpTypeMult
    BinOpTypeDiv
    BinOpTypeExp
    BinOpTypeLT
    BinOpTypeGT
    BinOpTypeEQ
    BinOpTypeLEQ
    BinOpTypeGEQ
    BinOpTypeNE
    BinOpTypeConcat // '&' in Excel
)

func (BinOpType) String

func (i BinOpType) String() string

type BinaryExpr

BinaryExpr is a binary expression.

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

func (BinaryExpr) Eval

func (b BinaryExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates the binary expression using the context given.

func (BinaryExpr) Reference

func (b BinaryExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for BinaryExpr.

func (BinaryExpr) String

func (b BinaryExpr) String() string

Eval evaluates the binary expression using the context given.

func (BinaryExpr) Update

func (b BinaryExpr) Update(q *update.UpdateQuery) Expression

Update updates references in the BinaryExpr after removing a row/column.

type Bool

Bool is a boolean expression.

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

func (Bool) Eval

func (b Bool) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns a boolean.

func (Bool) Reference

func (b Bool) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for Bool.

func (Bool) String

func (b Bool) String() string

String returns a string representation for Bool.

func (Bool) Update

func (b Bool) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect Bool.

type CellRef

CellRef is a reference to a single cell

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

func (CellRef) Eval

func (c CellRef) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of the cell reference.

func (CellRef) Reference

func (c CellRef) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a cell.

func (CellRef) String

func (c CellRef) String() string

String returns a string representation of CellRef.

func (CellRef) Update

func (c CellRef) Update(q *update.UpdateQuery) Expression

Update makes a reference to point to one of the neighboring cells after removing a row/column with respect to the update type.

type ConstArrayExpr

ConstArrayExpr is a constant array expression.

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

func (ConstArrayExpr) Eval

func (c ConstArrayExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of a constant array expression.

func (ConstArrayExpr) Reference

func (c ConstArrayExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for ConstArrayExpr.

func (ConstArrayExpr) String

func (c ConstArrayExpr) String() string

String returns a string representation of ConstArrayExpr.

func (ConstArrayExpr) Update

func (c ConstArrayExpr) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect ConstArrayExpr.

type Context

Context is a formula execution context. Formula evaluation uses the context to retreive information from sheets.

type Context interface {
    // Cell returns the result of evaluating a cell.
    Cell(ref string, ev Evaluator) Result

    // Sheet returns an evaluation context for a given sheet name.  This is used
    // when evaluating cells that pull data from other sheets (e.g. ='Sheet 2'!A1).
    Sheet(name string) Context

    // GetEpoch returns the time epoch of the context's Workbook.
    GetEpoch() time.Time

    // GetFilename returns the full filename of the context's Workbook.
    GetFilename() string

    // GetWidth returns a worksheet's column width.
    GetWidth(colIdx int) float64

    // GetFormat returns a cell's format.
    GetFormat(cellRef string) string

    // GetLabelPrefix returns cell's label prefix dependent on cell horizontal alignment.
    GetLabelPrefix(cellRef string) string

    // GetFormat returns if cell is protected.
    GetLocked(cellRef string) bool

    // HasFormula returns if cell contains formula.
    HasFormula(cellRef string) bool

    // IsBool returns if cell contains boolean value.
    IsBool(cellRef string) bool

    // IsDBCS returns if workbook default language is among DBCS.
    IsDBCS() bool

    // LastColumn returns the name of last column which contains data in range of context sheet's given rows.
    LastColumn(rowFrom, rowTo int) string

    // LastRow returns the name of last row which contains data in range of context sheet's given columns.
    LastRow(colFrom string) int

    // SetLocked returns sets cell's protected attribute.
    SetLocked(cellRef string, locked bool)

    // NamedRange returns a named range.
    NamedRange(name string) Reference

    // SetOffset is used so that the Context can evaluate cell references
    // differently when they are not absolute (e.g. not like '$A$5').  See the
    // shared formula support in Cell for usage.
    SetOffset(col, row uint32)
}

type EmptyExpr

EmptyExpr is an empty expression.

type EmptyExpr struct{}

func (EmptyExpr) Eval

func (e EmptyExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of an empty expression.

func (EmptyExpr) Reference

func (e EmptyExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for EmptyExpr.

func (EmptyExpr) String

func (e EmptyExpr) String() string

String returns an empty string for EmptyExpr.

func (EmptyExpr) Update

func (e EmptyExpr) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect EmptyExpr.

type Error

Error is an error expression.

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

func (Error) Eval

func (e Error) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of an error expression.

func (Error) Reference

func (e Error) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for Error.

func (Error) String

func (e Error) String() string

String returns an empty string for Error.

func (Error) Update

func (e Error) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect Error.

type ErrorType

ErrorType is a formula evaluation error type.

type ErrorType byte

ErrorType constants.

const (
    ErrorTypeValue ErrorType = iota
    ErrorTypeNull
    ErrorTypeRef
    ErrorTypeName
    ErrorTypeNum
    ErrorTypeSpill
    ErrorTypeNA
    ErrorTypeDivideByZero
)

type Evaluator

Evaluator is the interface for a formula evaluator. This is needed so we can pass it to the spreadsheet to let it evaluate formula cells before returning the results. NOTE: in order to implement Evaluator without cache embed noCache in it.

type Evaluator interface {
    Eval(ctx Context, formula string) Result
    SetCache(key string, value Result)
    GetFromCache(key string) (Result, bool)
    LastEvalIsRef() bool
}

func NewEvaluator

func NewEvaluator() Evaluator

NewEvaluator constructs a new defEval object which is the default formula evaluator.

type Expression

type Expression interface {
    Eval(ctx Context, ev Evaluator) Result
    Reference(ctx Context, ev Evaluator) Reference
    String() string
    Update(updateQuery *update.UpdateQuery) Expression
}

func NewBinaryExpr

func NewBinaryExpr(lhs Expression, op BinOpType, rhs Expression) Expression

NewBinaryExpr constructs a new binary expression with a given operator.

func NewBool

func NewBool(v string) Expression

NewBool constructs a new boolean expression.

func NewCellRef

func NewCellRef(v string) Expression

NewCellRef constructs a new cell reference.

func NewConstArrayExpr

func NewConstArrayExpr(data [][]Expression) Expression

NewConstArrayExpr constructs a new constant array expression with a given data.

func NewEmptyExpr

func NewEmptyExpr() Expression

NewEmptyExpr constructs a new empty expression.

func NewError

func NewError(v string) Expression

NewError constructs a new error expression from a string.

func NewFunction

func NewFunction(name string, args []Expression) Expression

NewFunction constructs a new function call expression.

func NewHorizontalRange

func NewHorizontalRange(v string) Expression

NewHorizontalRange constructs a new full rows range.

func NewNamedRangeRef

func NewNamedRangeRef(v string) Expression

NewNamedRangeRef constructs a new named range reference.

func NewNegate

func NewNegate(e Expression) Expression

NewNegate constructs a new negate expression.

func NewNumber

func NewNumber(v string) Expression

NewNumber constructs a new number expression.

func NewPrefixExpr

func NewPrefixExpr(pfx, exp Expression) Expression

NewPrefixExpr constructs an expression with prefix.

func NewPrefixHorizontalRange

func NewPrefixHorizontalRange(pfx Expression, v string) Expression

NewPrefixHorizontalRange constructs a new full rows range with prefix.

func NewPrefixRangeExpr

func NewPrefixRangeExpr(pfx, from, to Expression) Expression

NewPrefixRangeExpr constructs a new range with prefix.

func NewPrefixVerticalRange

func NewPrefixVerticalRange(pfx Expression, v string) Expression

NewPrefixVerticalRange constructs a new full columns range with prefix.

func NewRange

func NewRange(from, to Expression) Expression

NewRange constructs a new range.

func NewSheetPrefixExpr

func NewSheetPrefixExpr(s string) Expression

NewSheetPrefixExpr constructs a new prefix expression.

func NewString

func NewString(v string) Expression

NewString constructs a new string expression.

func NewVerticalRange

func NewVerticalRange(v string) Expression

NewVerticalRange constructs a new full columns range.

func Parse

func Parse(r io.Reader) Expression

Parse parses an io.Reader to get an Expression. If expression is parsed with an error, nil is returned

func ParseString

func ParseString(s string) Expression

Parse parses a string to get an Expression.

type Function

Function is a standard function whose result only depends on its arguments.

type Function func(args []Result) Result

func LookupFunction

func LookupFunction(name string) Function

LookupFunction looks up and returns a standard function or nil.

type FunctionCall

FunctionCall is a function call expression.

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

func (FunctionCall) Eval

func (f FunctionCall) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of a function call.

func (FunctionCall) Reference

func (f FunctionCall) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for FunctionCall.

func (FunctionCall) String

func (f FunctionCall) String() string

String returns a string representation of FunctionCall expression.

func (FunctionCall) Update

func (f FunctionCall) Update(q *update.UpdateQuery) Expression

Update updates the FunctionCall references after removing a row/column.

type FunctionComplex

FunctionComplex is a function whose result depends on its arguments and the context that it's in. As an example, INDIRECT is a complex function so that INDIRECT("A1") which returns the value of the "A1" cell in a sheet can use the context to reach into the sheet and pull out required values.

type FunctionComplex func(ctx Context, ev Evaluator, args []Result) Result

func LookupFunctionComplex

func LookupFunctionComplex(name string) FunctionComplex

LookupFunctionComplex looks up and returns a complex function or nil.

type HorizontalRange

HorizontalRange is a range expression that when evaluated returns a list of Results from references like 1:4 (all cells from rows 1 to 4).

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

func (HorizontalRange) Eval

func (r HorizontalRange) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a horizontal range returning a list of results or an error.

func (HorizontalRange) Reference

func (r HorizontalRange) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a horizontal range.

func (HorizontalRange) String

func (r HorizontalRange) String() string

String returns a string representation of a horizontal range.

func (HorizontalRange) Update

func (r HorizontalRange) Update(q *update.UpdateQuery) Expression

Update updates the horizontal range references after removing a row/column.

type Lexer

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

func NewLexer

func NewLexer() *Lexer

func (*Lexer) Next

func (l *Lexer) Next() *node

type NamedRangeRef

NamedRangeRef is a reference to a named range.

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

func (NamedRangeRef) Eval

func (n NamedRangeRef) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of the NamedRangeRef reference.

func (NamedRangeRef) Reference

func (n NamedRangeRef) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a named range.

func (NamedRangeRef) String

func (n NamedRangeRef) String() string

String returns a string representation of a named range.

func (NamedRangeRef) Update

func (n NamedRangeRef) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect named ranges.

type Negate

Negate is a negate expression like -A1.

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

func (Negate) Eval

func (n Negate) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of a Negate expression.

func (Negate) Reference

func (n Negate) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for Negate.

func (Negate) String

func (n Negate) String() string

String returns a string representation for Negate.

func (Negate) Update

func (n Negate) Update(q *update.UpdateQuery) Expression

Update updates references in the Negate after removing a row/column.

type Number

Number is a nubmer expression.

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

func (Number) Eval

func (n Number) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns a number.

func (Number) Reference

func (n Number) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for Number.

func (Number) String

func (n Number) String() string

String returns a string representation of Number.

func (Number) Update

func (n Number) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect Number.

type PrefixExpr

PrefixExpr is an expression containing reference to another sheet like Sheet1!A1 (the value of the cell A1 from sheet 'Sheet1').

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

func (PrefixExpr) Eval

func (p PrefixExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns an expression with prefix.

func (PrefixExpr) Reference

func (p PrefixExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to an expression with prefix.

func (PrefixExpr) String

func (p PrefixExpr) String() string

String returns a string representation of PrefixExpr.

func (PrefixExpr) Update

func (p PrefixExpr) Update(q *update.UpdateQuery) Expression

Update updates references in the PrefixExpr after removing a row/column.

type PrefixHorizontalRange

PrefixHorizontalRange is a range expression that when evaluated returns a list of Results from references like Sheet1!1:4 (all cells from rows 1 to 4 of sheet 'Sheet1').

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

func (PrefixHorizontalRange) Eval

func (r PrefixHorizontalRange) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a horizontal range with prefix returning a list of results or an error.

func (PrefixHorizontalRange) Reference

func (r PrefixHorizontalRange) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a horizontal range with prefix.

func (PrefixHorizontalRange) String

func (r PrefixHorizontalRange) String() string

String returns a string representation of a horizontal range with prefix.

func (PrefixHorizontalRange) Update

func (r PrefixHorizontalRange) Update(q *update.UpdateQuery) Expression

Update updates references in the PrefixHorizontalRange after removing a row/column.

type PrefixRangeExpr

PrefixRangeExpr is a range expression that when evaluated returns a list of Results from a given sheet like Sheet1!A1:B4 (all cells from A1 to B4 from a sheet 'Sheet1').

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

func (PrefixRangeExpr) Eval

func (p PrefixRangeExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a range with prefix returning a list of results or an error.

func (PrefixRangeExpr) Reference

func (p PrefixRangeExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a range with prefix.

func (PrefixRangeExpr) String

func (r PrefixRangeExpr) String() string

String returns a string representation of a range with prefix.

func (PrefixRangeExpr) Update

func (r PrefixRangeExpr) Update(q *update.UpdateQuery) Expression

Update updates references in the PrefixRangeExpr after removing a row/column.

type PrefixVerticalRange

PrefixVerticalRange is a range expression that when evaluated returns a list of Results from references like Sheet1!AA:IJ (all cells from columns AA to IJ of sheet 'Sheet1').

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

func (PrefixVerticalRange) Eval

func (r PrefixVerticalRange) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a vertical range with prefix returning a list of results or an error.

func (PrefixVerticalRange) Reference

func (r PrefixVerticalRange) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a vertical range with prefix.

func (PrefixVerticalRange) String

func (r PrefixVerticalRange) String() string

String returns a string representation of a vertical range with prefix.

func (PrefixVerticalRange) Update

func (r PrefixVerticalRange) Update(q *update.UpdateQuery) Expression

Update updates references in the PrefixVerticalRange after removing a row/column.

type Range

Range is a range expression that when evaluated returns a list of Results.

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

func (Range) Eval

func (r Range) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a range returning a list of results or an error.

func (Range) Reference

func (r Range) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a range.

func (Range) String

func (r Range) String() string

String returns a string of a range.

func (Range) Update

func (r Range) Update(q *update.UpdateQuery) Expression

Update updates references in the Range after removing a row/column.

type Reference

type Reference struct {
    Type  ReferenceType
    Value string
}

func MakeRangeReference

func MakeRangeReference(ref string) Reference

type ReferenceType

ReferenceType is a type of reference

type ReferenceType byte
const (
    ReferenceTypeInvalid ReferenceType = iota
    ReferenceTypeCell
    ReferenceTypeHorizontalRange
    ReferenceTypeVerticalRange
    ReferenceTypeNamedRange
    ReferenceTypeRange
    ReferenceTypeSheet
)

func (ReferenceType) String

func (i ReferenceType) String() string

type Result

Result is the result of a formula or cell evaluation .

type Result struct {
    ValueNumber  float64
    ValueString  string
    ValueList    []Result
    ValueArray   [][]Result
    IsBoolean    bool
    ErrorMessage string
    Type         ResultType

    Ref Reference
}

func Accrintm

func Accrintm(args []Result) Result

Accrintm implements the Excel ACCRINTM function.

func Amordegrc

func Amordegrc(args []Result) Result

Amordegrc implements the Excel AMORDEGRC function.

func Amorlinc

func Amorlinc(args []Result) Result

Amorlinc implements the Excel AMORLINC function.

func And

func And(args []Result) Result

And is an implementation of the Excel AND() function.

func Arabic

func Arabic(args []Result) Result

Arabic implements the Excel ARABIC function which parses roman numerals. It accepts one numeric argument.

func Atan2

func Atan2(args []Result) Result

Atan2 implements the Excel ATAN2 function. It accepts two numeric arguments, and the arguments are (x,y), reversed from normal to match Excel's behaviour.

func Average

func Average(args []Result) Result

Average implements the AVERAGE function. It differs slightly from Excel (and agrees with LibreOffice) in that boolean values are counted. As an example, AVERAGE of two cells containing TRUE & FALSE is 0.5 in LibreOffice and #DIV/0! in Excel. unioffice will return 0.5 in this case.

func Averagea

func Averagea(args []Result) Result

Averagea implements the AVERAGEA function, AVERAGEA counts cells that contain text as a zero where AVERAGE ignores them entirely.

func Base

func Base(args []Result) Result

Base is an implementation of the Excel BASE function that returns a string form of an integer in a specified base and of a minimum length with padded zeros.

func Ceiling

func Ceiling(args []Result) Result

Ceiling is an implementation of the CEILING function which returns the ceiling of a number.

func CeilingMath

func CeilingMath(args []Result) Result

CeilingMath implements _xlfn.CEILING.MATH which rounds numbers to the nearest multiple of the second argument, toward or away from zero as specified by the third argument.

func CeilingPrecise

func CeilingPrecise(args []Result) Result

CeilingPrecise is an implementation of the CEILING.PRECISE function which returns the ceiling of a number.

func Cell

func Cell(ctx Context, ev Evaluator, args []Result) Result

Cell is an implementation of the Excel CELL function that returns information about the formatting, location, or contents of a cell.

func Char

func Char(args []Result) Result

Char is an implementation of the Excel CHAR function that takes an integer in the range [0,255] and returns the corresponding ASCII character.

func Choose

func Choose(args []Result) Result

Choose implements the Excel CHOOSE function.

func Clean

func Clean(args []Result) Result

Clean is an implementation of the Excel CLEAN function that removes unprintable characters.

func Code

func Code(args []Result) Result

Code is an implementation of the Excel CODE function that returns the first character of the string as a number.

func Column

func Column(args []Result) Result

Column implements the Excel COLUMN function.

func Columns

func Columns(args []Result) Result

Columns implements the Excel COLUMNS function.

func Combin

func Combin(args []Result) Result

Combin is an implementation of the Excel COMBINA function whic returns the number of combinations.

func Combina

func Combina(args []Result) Result

Combina is an implementation of the Excel COMBINA function whic returns the number of combinations with repetitions.

func Concat

func Concat(args []Result) Result

Concat is an implementation of the Excel CONCAT() and deprecated CONCATENATE() function.

func Count

func Count(args []Result) Result

Count implements the COUNT function.

func CountBlank

func CountBlank(args []Result) Result

CountBlank implements the COUNTBLANK function.

func CountIf

func CountIf(args []Result) Result

CountIf implements the COUNTIF function.

func CountIfs

func CountIfs(args []Result) Result

CountIfs implements the COUNTIFS function.

func Counta

func Counta(args []Result) Result

Counta implements the COUNTA function.

func Coupdaybs

func Coupdaybs(args []Result) Result

Coupdaybs implements the Excel COUPDAYBS function.

func Coupdays

func Coupdays(args []Result) Result

Coupdays implements the Excel COUPDAYS function.

func Coupdaysnc

func Coupdaysnc(args []Result) Result

Coupdaysnc implements the Excel COUPDAYSNC function.

func Coupncd

func Coupncd(args []Result) Result

Coupncd implements the Excel COUPNCD function.

func Coupnum

func Coupnum(args []Result) Result

Coupnum implements the Excel COUPNUM function.

func Couppcd

func Couppcd(args []Result) Result

Couppcd implements the Excel COUPPCD function.

func Cumipmt

func Cumipmt(args []Result) Result

Cumipmt implements the Excel CUMIPMT function.

func Cumprinc

func Cumprinc(args []Result) Result

Cumprinc implements the Excel CUMPRINC function.

func Date

func Date(args []Result) Result

Date is an implementation of the Excel DATE() function.

func DateDif

func DateDif(args []Result) Result

DateDif is an implementation of the Excel DATEDIF() function.

func DateValue

func DateValue(args []Result) Result

DateValue is an implementation of the Excel DATEVALUE() function.

func Day

func Day(args []Result) Result

Day is an implementation of the Excel DAY() function.

func Days

func Days(args []Result) Result

Days is an implementation of the Excel DAYS() function.

func Db

func Db(args []Result) Result

Db implements the Excel DB function.

func Ddb

func Ddb(args []Result) Result

Ddb implements the Excel DDB function.

func Decimal

func Decimal(args []Result) Result

Decimal is an implementation of the Excel function DECIMAL() that parses a string in a given base and returns the numeric result.

func Degrees

func Degrees(args []Result) Result

Degrees is an implementation of the Excel function DEGREES() that converts radians to degrees.

func Disc

func Disc(args []Result) Result

Disc implements the Excel DISC function.

func Dollarde

func Dollarde(args []Result) Result

Dollarde implements the Excel DOLLARDE function.

func Dollarfr

func Dollarfr(args []Result) Result

Dollarfr implements the Excel DOLLARFR function.

func Duration

func Duration(args []Result) Result

Duration implements the Excel DURATION function.

func Edate

func Edate(args []Result) Result

Edate is an implementation of the Excel EDATE() function.

func Effect

func Effect(args []Result) Result

Effect implements the Excel EFFECT function.

func Eomonth

func Eomonth(args []Result) Result

Eomonth is an implementation of the Excel EOMONTH() function.

func Even

func Even(args []Result) Result

Even is an implementation of the Excel EVEN() that rounds a number to the nearest even integer.

func Exact

func Exact(args []Result) Result

Exact is an implementation of the Excel EXACT() which compares two strings.

func Fact

func Fact(args []Result) Result

Fact is an implementation of the excel FACT function which returns the factorial of a positive numeric input.

func FactDouble

func FactDouble(args []Result) Result

FactDouble is an implementation of the excel FACTDOUBLE function which returns the double factorial of a positive numeric input.

func False

func False(args []Result) Result

False is an implementation of the Excel FALSE() function. It takes no arguments.

func Find

func Find(args []Result) Result

Find is an implementation of the Excel FIND().

func Findb

func Findb(ctx Context, ev Evaluator, args []Result) Result

Findb is an implementation of the Excel FINDB().

func Floor

func Floor(args []Result) Result

Floor is an implementation of the FlOOR function.

func FloorMath

func FloorMath(args []Result) Result

FloorMath implements _xlfn.FLOOR.MATH which rounds numbers down to the nearest multiple of the second argument, toward or away from zero as specified by the third argument.

func FloorPrecise

func FloorPrecise(args []Result) Result

FloorPrecise is an implementation of the FlOOR.PRECISE function.

func Fv

func Fv(args []Result) Result

Fv implements the Excel FV function.

func Fvschedule

func Fvschedule(args []Result) Result

Fvschedule implements the Excel FVSCHEDULE function.

func GCD

func GCD(args []Result) Result

GCD implements the Excel GCD() function which returns the greatest common divisor of a range of numbers.

func HLookup

func HLookup(args []Result) Result

HLookup implements the HLOOKUP function that returns a matching value from a row in an array.

func If

func If(args []Result) Result

If is an implementation of the Excel IF() function. It takes one, two or three arguments.

func IfError

func IfError(args []Result) Result

IfError is an implementation of the Excel IFERROR() function. It takes two arguments.

func IfNA

func IfNA(args []Result) Result

IfNA is an implementation of the Excel IFNA() function. It takes two arguments.

func Ifs

func Ifs(args []Result) Result

Ifs is an implementation of the Excel IFS() function.

func Index

func Index(args []Result) Result

Index implements the Excel INDEX function.

func Indirect

func Indirect(ctx Context, ev Evaluator, args []Result) Result

Indirect is an implementation of the Excel INDIRECT function that returns the contents of a cell.

func Int

func Int(args []Result) Result

Int is an implementation of the Excel INT() function that rounds a number down to an integer.

func Intrate

func Intrate(args []Result) Result

Intrate implements the Excel INTRATE function.

func Ipmt

func Ipmt(args []Result) Result

Ipmt implements the Excel IPMT function.

func Irr

func Irr(args []Result) Result

Irr implements the Excel IRR function.

func IsBlank

func IsBlank(args []Result) Result

ISBLANK is an implementation of the Excel ISBLANK() function.

func IsErr

func IsErr(args []Result) Result

ISERR is an implementation of the Excel ISERR() function.

func IsError

func IsError(args []Result) Result

ISERROR is an implementation of the Excel ISERROR() function.

func IsEven

func IsEven(args []Result) Result

ISEVEN is an implementation of the Excel ISEVEN() function.

func IsFormula

func IsFormula(ctx Context, ev Evaluator, args []Result) Result

ISFORMULA is an implementation of the Excel ISFORMULA() function.

func IsLeapYear

func IsLeapYear(ctx Context, ev Evaluator, args []Result) Result

IsLeapYear is an implementation of the Excel ISLEAPYEAR() function.

func IsLogical

func IsLogical(ctx Context, ev Evaluator, args []Result) Result

IsLogical is an implementation of the Excel ISLOGICAL() function.

func IsNA

func IsNA(args []Result) Result

IsNA is an implementation of the Excel ISNA() function.

func IsNonText

func IsNonText(args []Result) Result

ISNONTEXT is an implementation of the Excel ISNONTEXT() function.

func IsNumber

func IsNumber(args []Result) Result

ISNUMBER is an implementation of the Excel ISNUMBER() function.

func IsOdd

func IsOdd(args []Result) Result

ISODD is an implementation of the Excel ISODD() function.

func IsRef

func IsRef(ctx Context, ev Evaluator, args []Result) Result

ISREF is an implementation of the Excel ISREF() function.

func IsText

func IsText(args []Result) Result

ISTEXT is an implementation of the Excel ISTEXT() function.

func Ispmt

func Ispmt(args []Result) Result

Ispmt implements the Excel ISPMT function.

func LCM

func LCM(args []Result) Result

LCM implements the Excel LCM() function which returns the least common multiple of a range of numbers.

func Large

func Large(args []Result) Result

Large implements the Excel LARGE function.

func Left

func Left(args []Result) Result

Left implements the Excel LEFT(string,[n]) function which returns the leftmost n characters.

func Len

func Len(args []Result) Result

Len is an implementation of the Excel LEN function that returns length of a string

func Log

func Log(args []Result) Result

Log implements the Excel LOG function which returns the log of a number. By default the result is base 10, however the second argument to the function can specify a different base.

func Lookup

func Lookup(args []Result) Result

Lookup implements the LOOKUP function that returns a matching value from a column, or from the same index in a second column.

func Lower

func Lower(args []Result) Result

Lower is an implementation of the Excel LOWER function that returns a lower case version of a string.

func MDeterm

func MDeterm(args []Result) Result

MDeterm is an implementation of the Excel MDETERM which finds the determinant of a matrix.

func MakeArrayResult

func MakeArrayResult(arr [][]Result) Result

MakeArrayResult constructs an array result (matrix).

func MakeBoolResult

func MakeBoolResult(b bool) Result

MakeBoolResult constructs a boolean result (internally a number).

func MakeEmptyResult

func MakeEmptyResult() Result

MakeEmptyResult is ued when parsing an empty argument.

func MakeErrorResult

func MakeErrorResult(msg string) Result

MakeErrorResult constructs a #VALUE! error with a given extra error message. The error message is for debugging formula evaluation only and is not stored in the sheet.

func MakeErrorResultType

func MakeErrorResultType(t ErrorType, msg string) Result

MakeErrorResultType makes an error result of a given type with a specified debug message

func MakeListResult

func MakeListResult(list []Result) Result

MakeListResult constructs a list result.

func MakeNumberResult

func MakeNumberResult(v float64) Result

MakeNumberResult constructs a number result.

func MakeStringResult

func MakeStringResult(s string) Result

MakeStringResult constructs a string result.

func Match

func Match(args []Result) Result

Match implements the MATCH function.

func Max

func Max(args []Result) Result

Max is an implementation of the Excel MAX() function.

func MaxA

func MaxA(args []Result) Result

MaxA is an implementation of the Excel MAXA() function.

func MaxIfs

func MaxIfs(args []Result) Result

MaxIfs implements the MAXIFS function.

func Mduration

func Mduration(args []Result) Result

Mduration implements the Excel MDURATION function.

func Median

func Median(args []Result) Result

Median implements the MEDIAN function that returns the median of a range of values.

func Mid

func Mid(args []Result) Result

Mid is an implementation of the Excel MID function that returns a copy of the string with each word capitalized.

func Min

func Min(args []Result) Result

Min is an implementation of the Excel MIN() function.

func MinA

func MinA(args []Result) Result

MinA is an implementation of the Excel MINA() function.

func MinIfs

func MinIfs(args []Result) Result

MinIfs implements the MINIFS function.

func Minute

func Minute(args []Result) Result

Minute is an implementation of the Excel MINUTE() function.

func Mirr

func Mirr(args []Result) Result

Mirr implements the Excel MIRR function.

func Mod

func Mod(args []Result) Result

Mod is an implementation of the Excel MOD function which returns the remainder after division. It requires two numeric argumnts.

func Month

func Month(args []Result) Result

Month is an implementation of the Excel MONTH() function.

func Mround

func Mround(args []Result) Result

Mround is an implementation of the Excel MROUND function. It is not a generic rounding function and has some oddities to match Excel's behavior.

func Multinomial

func Multinomial(args []Result) Result

Multinomial implements the excel MULTINOMIAL function.

func Munit

func Munit(args []Result) Result

Munit is an implementation of the Excel MUNIT function that returns an identity matrix.

func NA

func NA(args []Result) Result

NA is an implementation of the Excel NA() function that just returns the #N/A! error.

func Nominal

func Nominal(args []Result) Result

Nominal implements the Excel NOMINAL function.

func Not

func Not(args []Result) Result

Not is an implementation of the Excel NOT() function and takes a single argument.

func Now

func Now(args []Result) Result

Now is an implementation of the Excel NOW() function.

func Nper

func Nper(args []Result) Result

Nper implements the Excel NPER function.

func Npv

func Npv(args []Result) Result

Npv implements the Excel NPV function.

func Odd

func Odd(args []Result) Result

Odd is an implementation of the Excel ODD() that rounds a number to the nearest odd integer.

func Oddlprice

func Oddlprice(args []Result) Result

Oddlprice implements the Excel ODDLPRICE function.

func Oddlyield

func Oddlyield(args []Result) Result

Oddlyield implements the Excel ODDLYIELD function.

func Offset

func Offset(ctx Context, ev Evaluator, args []Result) Result

Offset is an implementation of the Excel OFFSET function.

func Or

func Or(args []Result) Result

Or is an implementation of the Excel OR() function and takes a variable number of arguments.

func Pduration

func Pduration(args []Result) Result

Pduration implements the Excel PDURATION function.

func Pi

func Pi(args []Result) Result

Pi is an implementation of the Excel Pi() function that just returns the Pi constant.

func Pmt

func Pmt(args []Result) Result

Pmt implements the Excel PMT function.

func Power

func Power(args []Result) Result

Power is an implementation of the Excel POWER function that raises a number to a power. It requires two numeric arguments.

func Ppmt

func Ppmt(args []Result) Result

Ppmt implements the Excel PPPMT function.

func Price

func Price(args []Result) Result

Price implements the Excel PRICE function.

func Pricedisc

func Pricedisc(args []Result) Result

Pricedisc implements the Excel PRICEDISC function.

func Pricemat

func Pricemat(args []Result) Result

Pricemat implements the Excel PRICEMAT function.

func Product

func Product(args []Result) Result

Product is an implementation of the Excel PRODUCT() function.

func Proper

func Proper(args []Result) Result

Proper is an implementation of the Excel PROPER function that returns a copy of the string with each word capitalized.

func Pv

func Pv(args []Result) Result

Pv implements the Excel PV function.

func Quotient

func Quotient(args []Result) Result

Quotient is an implementation of the Excel QUOTIENT function that returns the integer portion of division.

func Radians

func Radians(args []Result) Result

Radians is an implementation of the Excel function RADIANS() that converts degrees to radians.

func Rand

func Rand(args []Result) Result

Rand is an implementation of the Excel RAND() function that returns random numbers in the range [0,1).

func RandBetween

func RandBetween(args []Result) Result

RandBetween is an implementation of the Excel RANDBETWEEN() function that returns a random integer in the range specified.

func Rate

func Rate(args []Result) Result

Rate implements the Excel RATE function.

func Received

func Received(args []Result) Result

Received implements the Excel RECEIVED function.

func Replace

func Replace(args []Result) Result

Replace is an implementation of the Excel REPLACE().

func Rept

func Rept(args []Result) Result

Rept is an implementation of the Excel REPT function that returns n copies of a string.

func Right(args []Result) Result

Right implements the Excel RIGHT(string,[n]) function which returns the rightmost n characters.

func Roman

func Roman(args []Result) Result

Roman is an implementation of the Excel ROMAN function that convers numbers to roman numerals in one of 5 formats.

func Round

func Round(args []Result) Result

Round is an implementation of the Excel ROUND function that rounds a number to a specified number of digits.

func RoundDown

func RoundDown(args []Result) Result

RoundDown is an implementation of the Excel ROUNDDOWN function that rounds a number down to a specified number of digits.

func RoundUp

func RoundUp(args []Result) Result

RoundUp is an implementation of the Excel ROUNDUP function that rounds a number up to a specified number of digits.

func Row

func Row(args []Result) Result

Row implements the Excel ROW function.

func Rows

func Rows(args []Result) Result

Rows implements the Excel ROWS function.

func Rri

func Rri(args []Result) Result

Rri implements the Excel RRI function.

func Search(args []Result) Result

Search is an implementation of the Excel SEARCH().

func Searchb

func Searchb(ctx Context, ev Evaluator, args []Result) Result

Searchb is an implementation of the Excel SEARCHB().

func SeriesSum

func SeriesSum(args []Result) Result

SeriesSum implements the Excel SERIESSUM function.

func Sign

func Sign(args []Result) Result

func Sln

func Sln(args []Result) Result

Sln implements the Excel SLN function.

func Small

func Small(args []Result) Result

Small implements the Excel SMALL function.

func Substitute

func Substitute(args []Result) Result

Substitute is an implementation of the Excel SUBSTITUTE function.

func Sum

func Sum(args []Result) Result

Sum is an implementation of the Excel SUM() function.

func SumIf

func SumIf(args []Result) Result

SumIf implements the SUMIF function.

func SumIfs

func SumIfs(args []Result) Result

SumIfs implements the SUMIFS function.

func SumProduct

func SumProduct(args []Result) Result

SumProduct is an implementation of the Excel SUMPRODUCT() function.

func SumSquares

func SumSquares(args []Result) Result

SumSquares is an implementation of the Excel SUMSQ() function.

func Syd

func Syd(args []Result) Result

Syd implements the Excel SYD function.

func T

func T(args []Result) Result

T is an implementation of the Excel T function that returns whether the argument is text.

func Tbilleq

func Tbilleq(args []Result) Result

Tbilleq implements the Excel TBILLEQ function.

func Tbillprice

func Tbillprice(args []Result) Result

Tbillprice implements the Excel TBILLPRICE function.

func Tbillyield

func Tbillyield(args []Result) Result

Tbillyield implements the Excel TBILLYIELD function.

func Text

func Text(args []Result) Result

Text is an implementation of the Excel TEXT function.

func TextJoin

func TextJoin(args []Result) Result

TextJoin is an implementation of the Excel TEXTJOIN function.

func Time

func Time(args []Result) Result

Time is an implementation of the Excel TIME() function.

func TimeValue

func TimeValue(args []Result) Result

TimeValue is an implementation of the Excel TIMEVALUE() function.

func Today

func Today(args []Result) Result

Today is an implementation of the Excel TODAY() function.

func Transpose

func Transpose(args []Result) Result

Transpose implements the TRANSPOSE function that transposes a cell range.

func Trim

func Trim(args []Result) Result

Trim is an implementation of the Excel TRIM function that removes leading, trailing and consecutive spaces.

func True

func True(args []Result) Result

True is an implementation of the Excel TRUE() function. It takes no arguments.

func Trunc

func Trunc(args []Result) Result

func Unicode

func Unicode(args []Result) Result

func Upper

func Upper(args []Result) Result

Upper is an implementation of the Excel UPPER function that returns a upper case version of a string.

func VLookup

func VLookup(args []Result) Result

VLookup implements the VLOOKUP function that returns a matching value from a column in an array.

func Value

func Value(args []Result) Result

Value is an implementation of the Excel VALUE function.

func Vdb

func Vdb(args []Result) Result

Vdb implements the Excel VDB function.

func Xirr

func Xirr(args []Result) Result

Xirr implements the Excel XIRR function.

func Xnpv

func Xnpv(args []Result) Result

Xnpv implements the Excel XNPV function.

func Xor

func Xor(args []Result) Result

Xor is an implementation of the Excel XOR() function and takes a variable number of arguments. It's odd to say the least. If any argument is numeric, it returns true if the number of non-zero numeric arguments is odd and false otherwise. If no argument is numeric, it returns an error.

func Year

func Year(ctx Context, ev Evaluator, args []Result) Result

Year is an implementation of the Excel YEAR() function.

func YearFrac

func YearFrac(args []Result) Result

YearFrac is an implementation of the Excel YEARFRAC() function.

func Yield

func Yield(args []Result) Result

Yield implements the Excel YIELD function.

func Yielddisc

func Yielddisc(args []Result) Result

Yielddisc implements the Excel YIELDDISC function.

func Yieldmat

func Yieldmat(args []Result) Result

Yieldmat implements the Excel YIELDMAT function.

func (Result) AsNumber

func (r Result) AsNumber() Result

AsNumber attempts to intepret a string cell value as a number. Upon success, it returns a new number result, upon failure it returns the original result. This is used as functions return strings that can then act like number (e.g. LEFT(1.2345,3) + LEFT(1.2345,3) = 2.4)

func (Result) AsString

func (r Result) AsString() Result

func (Result) ListValues

func (r Result) ListValues() []Result

ListValues converts an array to a list or returns a lists values. This is used for functions that can accept an array, but don't care about ordering to reuse the list function logic.

func (Result) String

func (r Result) String() string

func (Result) Value

func (r Result) Value() string

Value returns a string version of the result.

type ResultType

ResultType is the type of the result

type ResultType byte

ResultType constants.

const (
    ResultTypeUnknown ResultType = iota
    ResultTypeNumber
    ResultTypeString
    ResultTypeList
    ResultTypeArray
    ResultTypeError
    ResultTypeEmpty
)

func (ResultType) String

func (i ResultType) String() string

type SheetPrefixExpr

SheetPrefixExpr is a reference to a sheet like Sheet1! (reference to sheet 'Sheet1').

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

func (SheetPrefixExpr) Eval

func (s SheetPrefixExpr) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns the result of a sheet expression.

func (SheetPrefixExpr) Reference

func (s SheetPrefixExpr) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a sheet.

func (SheetPrefixExpr) String

func (s SheetPrefixExpr) String() string

String returns a string representation of SheetPrefixExpr.

func (SheetPrefixExpr) Update

func (s SheetPrefixExpr) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect SheetPrefixExpr.

type String

String is a string expression.

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

func (String) Eval

func (s String) Eval(ctx Context, ev Evaluator) Result

Eval evaluates and returns a string.

func (String) Reference

func (s String) Reference(ctx Context, ev Evaluator) Reference

Reference returns an invalid reference for String.

func (String) String

func (s String) String() string

String returns a string representation of String.

func (String) Update

func (s String) Update(q *update.UpdateQuery) Expression

Update returns the same object as updating sheet references does not affect String.

type VerticalRange

VerticalRange is a range expression that when evaluated returns a list of Results from references like AA:IJ (all cells from columns AA to IJ).

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

func (VerticalRange) Eval

func (r VerticalRange) Eval(ctx Context, ev Evaluator) Result

Eval evaluates a vertical range returning a list of results or an error.

func (VerticalRange) Reference

func (r VerticalRange) Reference(ctx Context, ev Evaluator) Reference

Reference returns a string reference value to a vertical range.

func (VerticalRange) String

func (r VerticalRange) String() string

String returns a string representation of a vertical range.

func (VerticalRange) Update

func (r VerticalRange) Update(q *update.UpdateQuery) Expression

Update updates references in the VerticalRange after removing a row/column.