summaryrefslogtreecommitdiff
path: root/calc.go
diff options
context:
space:
mode:
Diffstat (limited to 'calc.go')
-rw-r--r--calc.go60
1 files changed, 59 insertions, 1 deletions
diff --git a/calc.go b/calc.go
index 698c51d..1610f5e 100644
--- a/calc.go
+++ b/calc.go
@@ -4,7 +4,7 @@
//
// Package excelize providing a set of functions that allow you to write to
// and read from XLSX / XLSM / XLTM files. Supports reading and writing
-// spreadsheet documents generated by Microsoft Exce™ 2007 and later. Supports
+// spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
// complex components by high compatibility, and provided streaming API for
// generating or reading data from a worksheet with huge amounts of data. This
// library needs Go version 1.10 or later.
@@ -323,6 +323,7 @@ var tokenPriority = map[string]int{
// MROUND
// MULTINOMIAL
// MUNIT
+// N
// NA
// NORM.DIST
// NORMDIST
@@ -339,6 +340,7 @@ var tokenPriority = map[string]int{
// OCT2HEX
// ODD
// OR
+// PERCENTILE.INC
// PERCENTILE
// PERMUT
// PERMUTATIONA
@@ -380,6 +382,7 @@ var tokenPriority = map[string]int{
// SUM
// SUMIF
// SUMSQ
+// T
// TAN
// TANH
// TODAY
@@ -4521,6 +4524,19 @@ func (fn *formulaFuncs) min(mina bool, argsList *list.List) formulaArg {
return newNumberFormulaArg(min)
}
+// PERCENTILEdotINC function returns the k'th percentile (i.e. the value below
+// which k% of the data values fall) for a supplied range of values and a
+// supplied k. The syntax of the function is:
+//
+// PERCENTILE.INC(array,k)
+//
+func (fn *formulaFuncs) PERCENTILEdotINC(argsList *list.List) formulaArg {
+ if argsList.Len() != 2 {
+ return newErrorFormulaArg(formulaErrorVALUE, "PERCENTILE.INC requires 2 arguments")
+ }
+ return fn.PERCENTILE(argsList)
+}
+
// PERCENTILE function returns the k'th percentile (i.e. the value below which
// k% of the data values fall) for a supplied range of values and a supplied
// k. The syntax of the function is:
@@ -4858,6 +4874,28 @@ func (fn *formulaFuncs) ISTEXT(argsList *list.List) formulaArg {
return newBoolFormulaArg(token.Type == ArgString)
}
+// N function converts data into a numeric value. The syntax of the function
+// is:
+//
+// N(value)
+//
+func (fn *formulaFuncs) N(argsList *list.List) formulaArg {
+ if argsList.Len() != 1 {
+ return newErrorFormulaArg(formulaErrorVALUE, "N requires 1 argument")
+ }
+ token, num := argsList.Front().Value.(formulaArg), 0.0
+ if token.Type == ArgError {
+ return token
+ }
+ if arg := token.ToNumber(); arg.Type == ArgNumber {
+ num = arg.Number
+ }
+ if token.Value() == "TRUE" {
+ num = 1
+ }
+ return newNumberFormulaArg(num)
+}
+
// NA function returns the Excel #N/A error. This error message has the
// meaning 'value not available' and is produced when an Excel Formula is
// unable to find a value that it needs. The syntax of the function is:
@@ -4883,6 +4921,26 @@ func (fn *formulaFuncs) SHEET(argsList *list.List) formulaArg {
return newNumberFormulaArg(float64(fn.f.GetSheetIndex(fn.sheet) + 1))
}
+// T function tests if a supplied value is text and if so, returns the
+// supplied text; Otherwise, the function returns an empty text string. The
+// syntax of the function is:
+//
+// T(value)
+//
+func (fn *formulaFuncs) T(argsList *list.List) formulaArg {
+ if argsList.Len() != 1 {
+ return newErrorFormulaArg(formulaErrorVALUE, "T requires 1 argument")
+ }
+ token := argsList.Front().Value.(formulaArg)
+ if token.Type == ArgError {
+ return token
+ }
+ if token.Type == ArgNumber {
+ return newStringFormulaArg("")
+ }
+ return newStringFormulaArg(token.Value())
+}
+
// Logical Functions
// AND function tests a number of supplied conditions and returns TRUE or