spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[LOWER] formula added and tested
author
Ben Vogt <[email protected]>
date
2017-06-23 23:47:25
stats
8 file(s) changed, 63 insertions(+), 8 deletions(-)
files
DOCS.md
TODO.md
dist/Formulas/AllFormulas.js
dist/Formulas/Text.js
src/Formulas/AllFormulas.ts
src/Formulas/Text.ts
tests/Formulas/TextTest.ts
tests/SheetFormulaTest.ts
  1diff --git a/DOCS.md b/DOCS.md
  2index 8199e0d..be16712 100644
  3--- a/DOCS.md
  4+++ b/DOCS.md
  5@@ -1585,3 +1585,11 @@
  6 @returns {string} 
  7 @constructor
  8 ```
  9+
 10+### LOWER 
 11+
 12+```
 13+  Converts text to lowercase. 
 14+@param value - Text to convert. 
 15+@constructor
 16+```
 17diff --git a/TODO.md b/TODO.md
 18index 57f5868..ad1d1c8 100644
 19--- a/TODO.md
 20+++ b/TODO.md
 21@@ -110,7 +110,6 @@ For example 64 tbs to a qt.
 22 * JOIN
 23 * LEFT
 24 * LEN
 25-* LOWER
 26 * MID
 27 * PROPER
 28 * REGEXEXTRACT - May be difficult considering language differences.
 29diff --git a/dist/Formulas/AllFormulas.js b/dist/Formulas/AllFormulas.js
 30index 60e0a5c..6856fe6 100644
 31--- a/dist/Formulas/AllFormulas.js
 32+++ b/dist/Formulas/AllFormulas.js
 33@@ -145,6 +145,7 @@ exports.SPLIT = Text_1.SPLIT;
 34 exports.CONCATENATE = Text_1.CONCATENATE;
 35 exports.CONVERT = Text_1.CONVERT;
 36 exports.TRIM = Text_1.TRIM;
 37+exports.LOWER = Text_1.LOWER;
 38 var Date_1 = require("./Date");
 39 exports.DATE = Date_1.DATE;
 40 exports.DATEVALUE = Date_1.DATEVALUE;
 41diff --git a/dist/Formulas/Text.js b/dist/Formulas/Text.js
 42index b7b92a3..5fb591f 100644
 43--- a/dist/Formulas/Text.js
 44+++ b/dist/Formulas/Text.js
 45@@ -416,7 +416,18 @@ exports.CONVERT = CONVERT;
 46  */
 47 var TRIM = function (value) {
 48     ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "TRIM");
 49-    var text = TypeConverter_1.TypeConverter.valueToString(value);
 50+    var text = TypeConverter_1.TypeConverter.firstValueAsString(value);
 51     return text.trim();
 52 };
 53 exports.TRIM = TRIM;
 54+/**
 55+ * Converts text to lowercase.
 56+ * @param value - Text to convert.
 57+ * @constructor
 58+ */
 59+var LOWER = function (value) {
 60+    ArgsChecker_1.ArgsChecker.checkLength(arguments, 1, "LOWER");
 61+    var text = TypeConverter_1.TypeConverter.firstValueAsString(value);
 62+    return text.toLowerCase();
 63+};
 64+exports.LOWER = LOWER;
 65diff --git a/src/Formulas/AllFormulas.ts b/src/Formulas/AllFormulas.ts
 66index a3d63ca..06e1d6d 100644
 67--- a/src/Formulas/AllFormulas.ts
 68+++ b/src/Formulas/AllFormulas.ts
 69@@ -151,7 +151,8 @@ import {
 70   SPLIT,
 71   CONCATENATE,
 72   CONVERT,
 73-  TRIM
 74+  TRIM,
 75+  LOWER
 76 } from "./Text"
 77 import {
 78   DATE,
 79@@ -349,5 +350,6 @@ export {
 80   FREQUENCY,
 81   GROWTH,
 82   TRIMMEAN,
 83-  SLOPE
 84+  SLOPE,
 85+  LOWER
 86 }
 87\ No newline at end of file
 88diff --git a/src/Formulas/Text.ts b/src/Formulas/Text.ts
 89index 2670cb2..774d04d 100644
 90--- a/src/Formulas/Text.ts
 91+++ b/src/Formulas/Text.ts
 92@@ -434,11 +434,23 @@ var CONVERT = function (value, startUnit, endUnit) {
 93  */
 94 var TRIM = function (value) {
 95   ArgsChecker.checkLength(arguments, 1, "TRIM");
 96-  var text = TypeConverter.valueToString(value);
 97+  var text = TypeConverter.firstValueAsString(value);
 98   return text.trim();
 99 };
100 
101 
102+/**
103+ * Converts text to lowercase.
104+ * @param value - Text to convert.
105+ * @constructor
106+ */
107+var LOWER =  function (value) {
108+  ArgsChecker.checkLength(arguments, 1, "LOWER");
109+  var text = TypeConverter.firstValueAsString(value);
110+  return text.toLowerCase();
111+};
112+
113+
114 export {
115   ARABIC,
116   CHAR,
117@@ -446,5 +458,6 @@ export {
118   SPLIT,
119   CONCATENATE,
120   CONVERT,
121-  TRIM
122+  TRIM,
123+  LOWER
124 }
125\ No newline at end of file
126diff --git a/tests/Formulas/TextTest.ts b/tests/Formulas/TextTest.ts
127index e2d36d8..84fab80 100644
128--- a/tests/Formulas/TextTest.ts
129+++ b/tests/Formulas/TextTest.ts
130@@ -5,7 +5,8 @@ import {
131   CONCATENATE,
132   SPLIT,
133   CONVERT,
134-  TRIM
135+  TRIM,
136+  LOWER
137 } from "../../src/Formulas/Text";
138 import * as ERRORS from "../../src/Errors";
139 import {
140@@ -148,3 +149,16 @@ test("TRIM", function(){
141     TRIM.apply(this, ["test", 5]);
142   }, ERRORS.NA_ERROR);
143 });
144+
145+
146+test("LOWER", function(){
147+  assertEquals(LOWER("TEST"), "test");
148+  assertEquals(LOWER(5), "5");
149+  assertEquals(LOWER(false), "false");
150+  catchAndAssertEquals(function() {
151+    LOWER.apply(this, []);
152+  }, ERRORS.NA_ERROR);
153+  catchAndAssertEquals(function() {
154+    LOWER.apply(this, ["test", 5]);
155+  }, ERRORS.NA_ERROR);
156+});
157diff --git a/tests/SheetFormulaTest.ts b/tests/SheetFormulaTest.ts
158index def495a..1483ee9 100644
159--- a/tests/SheetFormulaTest.ts
160+++ b/tests/SheetFormulaTest.ts
161@@ -695,6 +695,10 @@ test("Sheet SLOPE", function(){
162   assertFormulaEquals('=SLOPE([600, 800], [44, 4.1])', -5.012531328320802);
163 });
164 
165+test("Sheet LOWER", function(){
166+  assertFormulaEquals('=LOWER("str")', "str");
167+});
168+
169 test("Sheet *", function(){
170   assertFormulaEquals('= 10 * 10', 100);
171   assertFormulaEquals('= 10 * 0', 0);