Skip to content

Commit

Permalink
Text functions (#436)
Browse files Browse the repository at this point in the history
* LEN function

* TRIM function

* PROPER function

* CLEAN function

* REPT function

* More general method for coercion with defaults

* RIGHT function

* LEFT function

* Fix typo

* SEARCH function

* FIND function

* Introduce FunctionArgumentDefinition

* Align with develop

* translations

* changelog

* Update built-in-functions.md

reorder

* .

* Update built-in-functions.md

Co-authored-by: izulin <izulin@gmail.com>
Co-authored-by: Przemysław Uznański <40573492+izulin@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 22, 2020
1 parent 848d112 commit 5a4a49d
Show file tree
Hide file tree
Showing 33 changed files with 916 additions and 36 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Added helper functions for keeping track of cell/range dependencies: getCellPrecedents and getCellDependents. (#441)
- Added 9 text functions LEN, TRIM, PROPER, CLEAN, REPT, RIGHT, LEFT, SEARCH, FIND. (#221)
- Added helper methods for keeping track of cell/range dependencies: getCellPrecedents and getCellDependents. (#441)
- 4 financial functions FV, PMT, PPMT, IPMT.

### Fixed
Expand Down
19 changes: 14 additions & 5 deletions docs/guide/built-in-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ lets you design your own [custom functions](custom-functions).
| BITOR | Engineering | Returns a bitwise logical "or" of the parameters. | BITOR(Number1; Number2) |
| BITRSHIFT | Engineering | Shifts a number right by n bits. | BITRSHIFT(Number; Shift) |
| BITXOR | Engineering | Returns a bitwise logical "exclusive or" of the parameters. | BITXOR(Number1; Number2) |
| CHOOSE | Lookup and reference | Uses an index to return a value from a list of up to 30 values.| CHOOSE(Index; Value1; ...; Value30) |
| DEC2BIN | Engineering | Returns the binary number for the decimal number entered between –512 and 511. | DEC2BIN(Number; Places) |
| DEC2HEX | Engineering | Returns the hexadecimal number for the decimal number entered. | DEC2HEX(Number; Places) |
| DEC2OCT | Engineering | Returns the octal number for the decimal number entered. | DEC2OCT(Number; Places) |
Expand Down Expand Up @@ -104,12 +103,12 @@ lets you design your own [custom functions](custom-functions).
| OR | Logical | Returns TRUE if at least one argument is TRUE. | OR(Logicalvalue1; Logicalvalue2 ...Logicalvalue30) |
| TRUE | Logical | The logical value is set to TRUE. | TRUE() |
| XOR | Logical | Returns true if an odd number of arguments evaluates to TRUE. | XOR(Logicalvalue1; Logicalvalue2 ...Logicalvalue30) |
| CHOOSE | Lookup and reference | Uses an index to return a value from a list of up to 30 values.| CHOOSE(Index; Value1; ...; Value30) |
| COLUMNS | Lookup and reference | Returns the number of columns in the given reference. | COLUMNS(Array) |
| OFFSET | Lookup and reference | Returns the value of a cell offset by a certain number of rows and columns from a given reference point. | OFFSET(Reference; Rows; Columns; Height; Width) |
| ROWS | Lookup and reference | Returns the number of rows in the given reference. | ROWS(Array) |
| INDEX | Lookup and reference | Returns the content of a cell, specified by row and column number, or an optional range name. | INDEX(Reference; Row; Column; Range) |
| MATCH | Lookup and reference | Returns the relative position of an item in an array that matches a specified value. | MATCH(Searchcriterion; Lookuparray; Type) |
| TRANSPOSE | Matrix functions | Transposes the rows and columns of an array. | TRANSPOSE(Array) |
| VLOOKUP | Lookup and reference | Searches vertically with reference to adjacent cells to the right. | VLOOKUP(Search_Criterion; Array; Index; Sort_Order) |
| ABS | Math and trigonometry | Returns the absolute value of a number. | ABS(Number) |
| ACOS | Math and trigonometry | Returns the inverse trigonometric cosine of a number. | ACOS(Number) |
Expand All @@ -130,9 +129,6 @@ lets you design your own [custom functions](custom-functions).
| LN | Math and trigonometry | Returns the natural logarithm based on the constant e of a number. | LN(Number) |
| LOG | Math and trigonometry | Returns the logarithm of a number to the specified base. | LOG(Number; Base) |
| LOG10 | Math and trigonometry | Returns the base-10 logarithm of a number. | LOG10(Number) |
| MMULT | Matrix functions | Calculates the array product of two arrays. | MMULT(Array; Array) |
| MEDIANPOOL | Matrix functions | Calculates a smaller range which is a median of a Window_size, in a given Range, for every Stride element. | MEDIANPOOL(Range, Window_size, Stride) |
| MAXPOOL | Matrix functions | Calculates a smaller range which is a maximum of a Window_size, in a given Range, for every Stride element. | MAXPOOL(Range, Window_size, Stride) |
| MOD | Math and trigonometry | Returns the remainder when one integer is divided by another. | MOD(Dividend; Divisor) |
| ODD | Math and trigonometry | Rounds a positive number up to the nearest odd integer and a negative number down to the nearest odd integer. | ODD(Number) |
| PI | Math and trigonometry | Returns 3.14159265358979, the value of the mathematical constant PI to 14 decimal places. | PI() |
Expand All @@ -151,6 +147,10 @@ lets you design your own [custom functions](custom-functions).
| SUMSQ | Math and trigonometry | Returns the sum of the squares of the arguments | SUMSQ(Number1; Number2; ...; Number30) |
| TAN | Math and trigonometry | Returns the tangent of the given angle (in radians). | TAN(Number) |
| TRUNC | Math and trigonometry | Truncates a number by removing decimal places. | TRUNC(Number; Count) |
| MMULT | Matrix functions | Calculates the array product of two arrays. | MMULT(Array; Array) |
| MEDIANPOOL | Matrix functions | Calculates a smaller range which is a median of a Window_size, in a given Range, for every Stride element. | MEDIANPOOL(Range, Window_size, Stride) |
| MAXPOOL | Matrix functions | Calculates a smaller range which is a maximum of a Window_size, in a given Range, for every Stride element. | MAXPOOL(Range, Window_size, Stride) |
| TRANSPOSE | Matrix functions | Transposes the rows and columns of an array. | TRANSPOSE(Array) |
| AVERAGE | Statistical | Returns the average of the arguments. | AVERAGE(Number1; Number2; ...Number30) |
| AVERAGEA | Statistical | Returns the average of the arguments. | AVERAGEA(Value1; Value2; ... Value30) |
| AVERAGEIF | Statistical | Returns the arithmetic mean of all cells in a range that satisfy a given condition. | AVERAGEIF(Range; Criterion [; Average_Range ]) |
Expand All @@ -170,3 +170,12 @@ lets you design your own [custom functions](custom-functions).
| CONCATENATE | Text | Combines several text strings into one string. | CONCATENATE("Text1"; ...; "Text30") |
| SPLIT | Text | Divides text around a specified character or string, and puts each fragment into a separate cell in the row. | SPLIT(Text, Delimiter, [Split_by_each], [Remove_empty_text]) |
| TEXT | Text | Converts a number into text according to a given format. | TEXT(Number; Format) |
| LEN | Text | Returns length of a given text. | LEN("Text") |
| TRIM | Text | Strips extra spaces from text. | TRIM("Text") |
| PROPER | Text | Capitalizes words given text string. | PROPER("Text") |
| CLEAN | Text | Returns text that has been "cleaned" of line breaks and other non-printable characters. | CLEAN("Text") |
| REPT | Text | Repeats text a given number of times. | REPT("Text"; Number) |
| RIGHT | Text | Extracts a given number of characters from the right side of a text string. | RIGHT("Text"; Number) |
| LEFT | Text | Extracts a given number of characters from the left side of a text string. | LEFT("Text"; Number) |
| SEARCH | Text | Returns the location of one text string inside another. (Allows the use of wildcards.) | SEARCH( "Text1"; "Text2"[; Number]) |
| FIND | Text | Returns the location of one text string inside another. | FIND( "Text1"; "Text2"[; Number]) |
9 changes: 9 additions & 0 deletions src/i18n/languages/csCZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary: RawTranslationPackage = {
CEILING: 'ZAOKR.NAHORU',
CHAR: 'ZNAK',
CHOOSE: 'ZVOLIT',
CLEAN: 'VYČISTIT',
CODE: 'KÓD',
COLUMNS: 'SLOUPCE',
CONCATENATE: 'CONCATENATE',
Expand Down Expand Up @@ -67,6 +68,7 @@ const dictionary: RawTranslationPackage = {
EVEN: 'ZAOKROUHLIT.NA.SUDÉ',
EXP: 'EXP',
FALSE: 'NEPRAVDA',
FIND: 'NAJÍT',
FV: 'BUDHODNOTA',
IF: 'KDYŽ',
IFERROR: 'IFERROR',
Expand All @@ -82,6 +84,8 @@ const dictionary: RawTranslationPackage = {
ISNUMBER: 'JE.ČISLO',
ISODD: 'ISODD',
ISTEXT: 'JE.TEXT',
LEFT: 'ZLEVA',
LEN: 'DÉLKA',
LN: 'LN',
LOG: 'LOGZ',
LOG10: 'LOG',
Expand All @@ -104,12 +108,16 @@ const dictionary: RawTranslationPackage = {
PMT: 'PLATBA',
POWER: 'POWER',
PPMT: 'PLATBA.ZÁKLAD',
PROPER: 'VELKÁ2',
RADIANS: 'RADIANS',
RAND: 'NÁHČÍSLO',
REPT: 'OPAKOVAT',
RIGHT: 'ZPRAVA',
ROUND: 'ZAOKROUHLIT',
ROUNDDOWN: 'ROUNDDOWN',
ROUNDUP: 'ROUNDUP',
ROWS: 'ŘÁDKY',
SEARCH: 'HLEDAT',
SIN: 'SIN',
SPLIT: 'SPLIT',
SQRT: 'ODMOCNINA',
Expand All @@ -122,6 +130,7 @@ const dictionary: RawTranslationPackage = {
TAN: 'TG',
TEXT: 'HODNOTA.NA.TEXT',
TRANSPOSE: 'TRANSPOZICE',
TRIM: 'PROČISTIT',
TRUE: 'PRAVDA',
TRUNC: 'USEKNOUT',
VLOOKUP: 'SVYHLEDAT',
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/languages/daDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary: RawTranslationPackage = {
CEILING: 'AFRUND.LOFT',
CHAR: 'CHAR',
CHOOSE: 'VÆLG',
CLEAN: 'RENS',
CODE: 'KODE',
COLUMNS: 'KOLONNER',
CONCATENATE: 'SAMMENKÆDNING',
Expand Down Expand Up @@ -67,6 +68,7 @@ const dictionary: RawTranslationPackage = {
EVEN: 'LIGE',
EXP: 'EKSP',
FALSE: 'FALSE',
FIND: 'FIND',
FV: 'FV',
IF: 'HVIS',
IFERROR: 'HVIS.FEJL',
Expand All @@ -82,6 +84,8 @@ const dictionary: RawTranslationPackage = {
ISNUMBER: 'ER.TAL',
ISODD: 'ER.ULIGE',
ISTEXT: 'ER.TEKST',
LEFT: 'VENSTRE',
LEN: 'LÆNGDE',
LN: 'LN',
LOG: 'LOG',
LOG10: 'LOG10',
Expand All @@ -104,12 +108,16 @@ const dictionary: RawTranslationPackage = {
PMT: 'YDELSE',
POWER: 'POTENS',
PPMT: 'H.YDELSE',
PROPER: 'STORT.FORBOGSTAV',
RADIANS: 'RADIANER',
RAND: 'SLUMP',
REPT: 'GENTAG',
RIGHT: 'HØJRE',
ROUND: 'AFRUND',
ROUNDDOWN: 'RUND.NED',
ROUNDUP: 'RUND.OP',
ROWS: 'RÆKKER',
SEARCH: 'SØG',
SIN: 'SIN',
SPLIT: 'SPLIT',
SQRT: 'KVROD',
Expand All @@ -122,6 +130,7 @@ const dictionary: RawTranslationPackage = {
TAN: 'TAN',
TEXT: 'TEKST',
TRANSPOSE: 'TRANSPONER',
TRIM: 'FJERN.OVERFLØDIGE.BLANKE',
TRUE: 'TRUE',
TRUNC: 'AFKORT',
VLOOKUP: 'LOPSLAG',
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/languages/deDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary: RawTranslationPackage = {
CEILING: 'OBERGRENZE',
CHAR: 'ZEICHEN',
CHOOSE: 'WAHL',
CLEAN: 'SÄUBERN',
CODE: 'CODE',
COLUMNS: 'SPALTEN',
CONCATENATE: 'VERKETTEN',
Expand Down Expand Up @@ -67,6 +68,7 @@ const dictionary: RawTranslationPackage = {
EVEN: 'GERADE',
EXP: 'EXP',
FALSE: 'FALSCH',
FIND: 'FINDEN',
FV: 'ZW',
IF: 'WENN',
IFERROR: 'WENNFEHLER',
Expand All @@ -82,6 +84,8 @@ const dictionary: RawTranslationPackage = {
ISNUMBER: 'ISTZAHL',
ISODD: 'ISTUNGERADE',
ISTEXT: 'ISTTEXT',
LEFT: 'LINKS',
LEN: 'LÄNGE',
LN: 'LN',
LOG: 'LOG',
LOG10: 'LOG10',
Expand All @@ -104,12 +108,16 @@ const dictionary: RawTranslationPackage = {
PMT: 'RMZ',
POWER: 'POTENZ',
PPMT: 'KAPZ',
PROPER: 'GROSS2',
RADIANS: 'BOGENMASS',
RAND: 'ZUFALLSZAHL',
REPT: 'WIEDERHOLEN',
RIGHT: 'RECHTS',
ROUND: 'RUNDEN',
ROUNDDOWN: 'ABRUNDEN',
ROUNDUP: 'AUFRUNDEN',
ROWS: 'ZEILEN',
SEARCH: 'SUCHEN',
SIN: 'SIN',
SPLIT: 'SPLIT',
SQRT: 'WURZEL',
Expand All @@ -122,6 +130,7 @@ const dictionary: RawTranslationPackage = {
TAN: 'TAN',
TEXT: 'TEXT',
TRANSPOSE: 'MTRANS',
TRIM: 'GLÄTTEN',
TRUE: 'WAHR',
TRUNC: 'KÜRZEN',
VLOOKUP: 'SVERWEIS',
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/languages/enGB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary: RawTranslationPackage = {
CEILING: 'CEILING',
CHAR: 'CHAR',
CHOOSE: 'CHOOSE',
CLEAN: 'CLEAN',
CODE: 'CODE',
COLUMNS: 'COLUMNS',
CONCATENATE: 'CONCATENATE',
Expand Down Expand Up @@ -67,6 +68,7 @@ const dictionary: RawTranslationPackage = {
EVEN: 'EVEN',
EXP: 'EXP',
FALSE: 'FALSE',
FIND: 'FIND',
FV: 'FV',
IF: 'IF',
IFERROR: 'IFERROR',
Expand All @@ -82,6 +84,8 @@ const dictionary: RawTranslationPackage = {
ISNUMBER: 'ISNUMBER',
ISODD: 'ISODD',
ISTEXT: 'ISTEXT',
LEFT: 'LEFT',
LEN: 'LEN',
LN: 'LN',
LOG: 'LOG',
LOG10: 'LOG10',
Expand All @@ -104,12 +108,16 @@ const dictionary: RawTranslationPackage = {
PMT: 'PMT',
PPMT: 'PPMT',
POWER: 'POWER',
PROPER: 'PROPER',
RADIANS: 'RADIANS',
RAND: 'RAND',
REPT: 'REPT',
RIGHT: 'RIGHT',
ROUND: 'ROUND',
ROUNDDOWN: 'ROUNDDOWN',
ROUNDUP: 'ROUNDUP',
ROWS: 'ROWS',
SEARCH: 'SEARCH',
SIN: 'SIN',
SPLIT: 'SPLIT',
SQRT: 'SQRT',
Expand All @@ -122,6 +130,7 @@ const dictionary: RawTranslationPackage = {
TAN: 'TAN',
TEXT: 'TEXT',
TRANSPOSE: 'TRANSPOSE',
TRIM: 'TRIM',
TRUE: 'TRUE',
TRUNC: 'TRUNC',
VLOOKUP: 'VLOOKUP',
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/languages/esES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const dictionary: RawTranslationPackage = {
CEILING: 'MULTIPLO.SUPERIOR',
CHAR: 'CARACTER',
CHOOSE: 'ELEGIR',
CLEAN: 'LIMPIAR',
CODE: 'CODIGO',
COLUMNS: 'COLUMNAS',
CONCATENATE: 'CONCATENAR',
Expand Down Expand Up @@ -67,6 +68,7 @@ export const dictionary: RawTranslationPackage = {
EVEN: 'REDONDEA.PAR',
EXP: 'EXP',
FALSE: 'FALSO',
FIND: 'ENCONTRAR',
FV: 'VF',
IF: 'SI',
IFERROR: 'SI.ERROR',
Expand All @@ -82,6 +84,8 @@ export const dictionary: RawTranslationPackage = {
ISNUMBER: 'ESNUMERO',
ISODD: 'ES.IMPAR',
ISTEXT: 'ESTEXTO',
LEFT: 'IZQUIERDA',
LEN: 'LARGO',
LN: 'LN',
LOG: 'LOG',
LOG10: 'LOG10',
Expand All @@ -104,12 +108,16 @@ export const dictionary: RawTranslationPackage = {
PMT: 'PAGO',
POWER: 'POTENCIA',
PPMT: 'PAGOPRIN',
PROPER: 'NOMPROPIO',
RADIANS: 'RADIANES',
RAND: 'ALEATORIO',
REPT: 'REPETIR',
RIGHT: 'DERECHA',
ROUND: 'REDONDEAR',
ROUNDDOWN: 'REDONDEAR.MENOS',
ROUNDUP: 'REDONDEAR.MAS',
ROWS: 'FILAS',
SEARCH: 'HALLAR',
SIN: 'SENO',
SPLIT: 'SPLIT',
SQRT: 'RAIZ',
Expand All @@ -122,6 +130,7 @@ export const dictionary: RawTranslationPackage = {
TAN: 'TAN',
TEXT: 'TEXTO',
TRANSPOSE: 'TRANSPONER',
TRIM: 'ESPACIOS',
TRUE: 'VERDADERO',
TRUNC: 'TRUNCAR',
VLOOKUP: 'BUSCARV',
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/languages/fiFI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dictionary: RawTranslationPackage = {
CEILING: 'PYÖRISTÄ.KERR.YLÖS',
CHAR: 'MERKKI',
CHOOSE: 'VALITSE.INDEKSI',
CLEAN: 'SIIVOA',
CODE: 'KOODI',
COLUMNS: 'SARAKKEET',
CONCATENATE: 'KETJUTA',
Expand Down Expand Up @@ -67,6 +68,7 @@ const dictionary: RawTranslationPackage = {
EVEN: 'PARILLINEN',
EXP: 'EKSPONENTTI',
FALSE: 'EPÄTOSI',
FIND: 'ETSI',
FV: 'TULEVA.ARVO',
IF: 'JOS',
IFERROR: 'JOSVIRHE',
Expand All @@ -82,6 +84,8 @@ const dictionary: RawTranslationPackage = {
ISNUMBER: 'ONLUKU',
ISODD: 'ONPARITON',
ISTEXT: 'ONTEKSTI',
LEFT: 'VASEN',
LEN: 'PITUUS',
LN: 'LUONNLOG',
LOG: 'LOG',
LOG10: 'LOG10',
Expand All @@ -104,12 +108,16 @@ const dictionary: RawTranslationPackage = {
PMT: 'MAKSU',
POWER: 'POTENSSI',
PPMT: 'PPMT',
PROPER: 'ERISNIMI',
RADIANS: 'RADIAANIT',
RAND: 'SATUNNAISLUKU',
REPT: 'TOISTA',
RIGHT: 'OIKEA',
ROUND: 'PYÖRISTÄ',
ROUNDDOWN: 'PYÖRISTÄ.DES.ALAS',
ROUNDUP: 'PYÖRISTÄ.DES.YLÖS',
ROWS: 'RIVIT',
SEARCH: 'KÄY.LÄPI',
SIN: 'SIN',
SPLIT: 'SPLIT',
SQRT: 'NELIÖJUURI',
Expand All @@ -122,6 +130,7 @@ const dictionary: RawTranslationPackage = {
TAN: 'TAN',
TEXT: 'TEKSTI',
TRANSPOSE: 'TRANSPONOI',
TRIM: 'POISTA.VÄLIT',
TRUE: 'TOSI',
TRUNC: 'KATKAISE',
VLOOKUP: 'PHAKU',
Expand Down
Loading

0 comments on commit 5a4a49d

Please sign in to comment.