Funcions de text

Aquesta secció conté descripcions de les funcions de text.

Per a accedir a aquesta ordre...

Insereix ▸ Funció ▸ categoria Text


Using double quotation marks in formulas

To include a text string in a formula, place the text string between two double quotation marks (") and Calc takes the characters in the string without attempting to interpret them. For example, the formula ="Hello world!" displays the text string Hello world! in the cell, with no surrounding double quotation marks.

The more complex formula =CONCATENATE("Life is really simple, "; "but we insist on making it complicated "; "(Confucius).") concatenates three individual strings in double quotation marks, outputting Life is really simple, but we insist on making it complicated (Confucius).

To place a literal double quotation mark within a string inside a formula, two methods can be used:

  1. You can "escape" the double quotation mark with an additional double quotation mark, and Calc treats the escaped double quotation mark as a literal value. For example, the formula ="My name is ""John Doe""." outputs the string My name is "John Doe". Another simple example is the formula =UNICODE("""") which returns 34, the decimal value of the Unicode quotation mark character (U+0022) — here the first and fourth double quotation marks indicate the beginning and end of the string, while the second double quotation mark escapes the third.

  2. You can use the CHAR function or the UNICHAR function to insert a double quotation mark. For example, the formula =UNICHAR(34) & "The Catcher in the Rye" & UNICHAR(34) & " is a famous book by J. D. Salinger." displays the string "The Catcher in the Rye" is a famous book by J. D. Salinger.

Be aware that Calc's AutoCorrect function may modify double quotation marks. AutoCorrect should not change the double quotation marks within formula cells but may change those used in non-formula cells containing text. For example, if you copy a string that is surrounded by some other form of typographical double quotation marks, such as the left double quotation mark (U+201C) and the right double quotation mark (U+201D), and then paste into a formula cell, an error may result. Open the Double Quotes area of the Tools - AutoCorrect Options - Localized Options dialog to set the characters used to automatically correct the start and end typographical double quotation marks. Uncheck the Replace toggle button to disable the feature.

ARABIC

Returns the numeric value corresponding to a Roman number expressed as text.

ASC

Converts double-byte (full-width) characters to single-byte (half-width) ASCII and katakana characters.

JIS

Converts single-byte (half-width) ASCII or katakana characters to double-byte (full-width) characters.

REGEX

Troba i extreu, o opcionalment reemplaça, text, fent servir expressions regulars.

ROMA

Converteix un nombre en xifres romanes. L'interval de valors ha de ser entre 0 i 3999. És possible especificar un mode de simplificació en un interval de 0 a 4.

VALUE

Converts the string representation of a number to numeric form. If the supplied string is a valid date, time, or date-time, the corresponding date-time serial number is returned.

WEBSERVICE

Obté contingut web a partir d'un URI.

FILTERXML

Aplica una expressió XPath en un document XML.

ENCODEURL

Returns a URL-encoded string.

BASE

Converts a positive integer to a specified base into a text from the numbering system. The digits 0-9 and the letters A-Z are used.

Sintaxi

BASE(Number; Radix [; MinimumLength])

Nombre és l'enter positiu que s'ha de convertir.

Radix indicates the base of the numeral system. It may be any positive integer between 2 and 36.

LongitudMínima (opcional) determina la longitud mínima de la seqüència de caràcters que s'ha creat. Si el text és més curt que la longitud mínima que s'ha indicat, s'afegeixen zeros a l'esquerra de la cadena.

Exemple

=BASE(17;10;4) retorna 0017 en el sistema decimal.

=BASE(17;2) retorna 10001 en el sistema binari.

=BASE(255;16;4) retorna 00FF en el sistema hexadecimal.

Vegeu també

DECIMAL

CARAC

Converteix un nombre en un caràcter segons la taula de codi actual. El nombre pot ser un enter de dos o tres dígits.

Els codis més grans que 127 poden dependre del mapatge de caràcters del vostre sistema (per exemple, iso-8859-1, iso-8859-2, Windows-1252, Windows-1250), i per tant és possible que no siguin portàtils.

Sintaxi

CARAC(Nombre)

Nombre és un nombre entre 1 i 255 que representa el valor de codi del caràcter.

Exemple

=CARAC(100) retorna el caràcter d.

="abc" & CARAC(10) & "def" insereix un caràcter de línia nova a la cadena.

CARACUNI

Converteix un codi numèric en un caràcter o lletra Unicode.

Sintaxi

CARACUNI(nombre)

Exemple

=CARACUNI(169) retorna el caràcter de drets d'autor ©.

tip

Vegeu també la funció UNICODE().


CERCA

Retorna la posició d'un segment de text en una cadena de caràcters. Podeu definir l'inici de la cerca com una opció. El text de cerca pot ser un nombre o qualsevol seqüència de caràcters. En la cerca no es distingeix entre majúscules i minúscules. Si el text no es troba, es retorna l'error 519 (#VALOR).

The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Sintaxi

SEARCH("FindText"; "Text" [; Position])

TextDeCerca és el text que s'ha de cercar.

Text és el text on es du a terme la cerca.

Posició (opcional) és la posició en el text on ha de començar la cerca.

Exemple

=CERCA(54;998877665544) retorna 10.

CODI

Retorna un codi numèric per al primer caràcter d'una cadena de text.

Sintaxi

CODI("Text")

Text és el text del qual s'ha de trobar el codi del primer caràcter.

Els codis més grans que 127 poden dependre del mapatge de caràcters del vostre sistema (per exemple, iso-8859-1, iso-8859-2, Windows-1252, Windows-1250), i per tant és possible que no siguin portàtils.

Exemple

=CODI("Jerònim") retorna 74, =CODI("jeroglífic") retorna 106.

note

El codi que s'utilitza aquí no fa referència a l'ASCII, sinó a la taula de codi actual.


CONCATENA

Combina diverses cadenes de text en una sola cadena.

Sintaxi

CONCATENATE(String 1 [; String 2 [; … [; String 255]]])

String 1[; String 2][; … ;[String 255]] are strings or references to cells containing strings.

Exemple

=CONCATENA("Bon ";"dia ";"Sra. ";"Pla") retorna: Bon dia Sra. Pla.

DECIMAL

Converts text that represents a number in a numeral system with the given base radix to a positive integer. The radix must be in the range 2 to 36. Spaces and tabs are ignored. The Text field is not case-sensitive.

If the radix is 16, a leading x or X or 0x or 0X, and an appended h or H, are disregarded. If the radix is 2, an appended b or B is disregarded. Other characters that do not belong to the numeral system generate an error.

Sintaxi

DECIMAL("Text"; BaseDeNumeració)

Text és el text a convertir.

Radix indicates the base of the numeral system. It may be any positive integer between 2 and 36.

Exemple

=DECIMAL("17";10) retorna 17.

=DECIMAL("FACE";16) retorna 64206.

=DECIMAL("0101";2) retorna 5.

Vegeu també

BASE

DRETA

Retorna l'últim caràcter o caràcters d'un text.

Sintaxi

RIGHT("Text" [; Number])

Text és el text del qual es determinarà la part dreta.

Number (optional) is the number of characters from the right part of the text. If this parameter is not defined, one character is returned.

Exemple

=DRETA("Sun";2) retorna un.

ESQUERRA

Retorna el primer caràcter o caràcters d'un text.

Sintaxi

LEFT("Text" [; Number])

Text és el text on s'han de determinar les paraules inicials parcials.

Nombre (opcional) indica el nombre de caràcters del text d'inici. Si no es defineix aquest paràmetre, es retorna un caràcter.

Exemple

=ESQUERRA("sortida";3) retorna «sor».

ESQUERRAB

Retorna el primer caràcter o caràcters d'un text DBCS.

tip

Aquesta funció és disponible des de la versió 4.2 del LibreOffice.


Sintaxi

LEFTB("Text" [; Number_bytes])

Text és el text del qual s'han de determinar les paraules parcials inicials.

NombreBytes (opcional) indica el nombre de caràcters que voleu extreure amb ESQUERRAB. Si no es defineix aquest paràmetre, es retorna un únic caràcter.

Exemple

=LEFTB("中国";1) returns " " (1 byte is only half a DBCS character and a space character is returned instead).

=LEFTB("中国";2) returns "中" (2 bytes constitute one complete DBCS character).

=LEFTB("中国";3) returns "中 " (3 bytes constitute one DBCS character and a half; the last character returned is therefore a space character).

=LEFTB("中国";4) returns "中国" (4 bytes constitute two complete DBCS characters).

=LEFTB("office";3) returns "off" (3 non-DBCS characters each consisting of 1 byte).

EXACTE

Compara dues cadenes de text i retorna CERT si són idèntiques. Aquesta funció distingeix entre majúscules i minúscules.

Sintaxi

EXACTE("Text1"; "Text2")

Text1 fa referència al primer text que s'ha de comparar.

Text2 és el segon text que s'ha de comparar.

Exemple

=EXACTE("microsystems";"Microsystems") retorna FALS.

FIX

Returns a number as text with a specified number of decimal places and optional thousands separators.

Sintaxi

FIXED(Number; [Decimals = 2 [; NoThousandsSeparators = FALSE]])

Number is rounded to Decimals places (after the decimal separator) and the result formatted as text, using locale-specific settings.

Decimals (optional) refers to the number of decimal places to be displayed. If Decimals is negative, Number is rounded to ABS(Decimals) places to the left from the decimal point. If Decimals is a fraction, it is truncated actually ignoring what is the closest integer.

NoThousandsSeparators (optional) determines whether the thousands separator is used. If it is TRUE or non-zero, then group separators are omitted from the resulting string. If the parameter is equal to 0 or if it is missing altogether, the thousands separators of your current locale setting are displayed.

Exemple

=FIX(1234567,89;3) retorna 1.234.567,890 com a cadena de text.

=FIXED(123456.789;;TRUE) returns 123456.79 as a text string.

=FIXED(12345.6789;-2) returns 12,300 as a text string.

=FIXED(12134567.89;-3;1) returns 12135000 as a text string.

=FIXED(12345.789;3/4) returns 12,346 as a text string.

=FIXED(12345.789;8/5) returns 12,345.8 as a text string.

INICIALMAJUSC

Escriu amb majúscula la primera lletra de totes les paraules d'una cadena de text.

Sintaxi

INICIALMAJUSC("Text")

Text es refereix al text que s'ha de convertir.

Exemple

=PROPER("the document foundation") returns The Document Foundation.

LONG

Retorna la longitud d'una cadena; hi inclou els espais.

Sintaxi

LONG("Text")

Text és el text la longitud del qual s'ha de determinar.

Exemple

=LONG("Bon dia") retorna 7.

=LONG(12345,67) retorna 8.

LONGB

For double-byte character set (DBCS) languages, returns the number of bytes used to represent the characters in a text string.

tip

Aquesta funció és disponible des de la versió 4.2 del LibreOffice.


Sintaxi

LONGB("Text")

Text és el text la longitud del qual s'ha de determinar.

Exemple

ESQUERRAB("中国";2) retorna "中" (2 bytes formen un caràcter DBCS complet).

ESQUERRAB("中国";2) retorna 4 (2 bytes formen un caràcter DBCS).

ESQUERRAB("oficina") retorna " 6 (6 caràcters no-DBCS, cadascun format per 1 byte).

=LONGB("Bon dia") retorna 7.

=LONGB(12345,67) retorna 8.

MAJUSC

Converteix la cadena indicada en el camp de text que s'ha d'escriure amb majúscules.

Sintaxi

MAJUSC("Text")

Text fa referència a les lletres en minúscules que voleu convertir en majúscules.

Exemple

=MAJUSC("Bon dia") retorna BON DIA.

MIDB

Retorna la cadena de text d'un text DBCS. Els paràmetres indiquen la posició inicial i el nombre de caràcters.

tip

Aquesta funció és disponible des de la versió 4.2 del LibreOffice.


Sintaxi

MIGB("Text"; Inici; NombreBytes)

Text és el text que conté els caràcters que s'han d'extreure.

Inici és la posició del primer caràcter del text que s'ha d'extreure.

NombreBytes indica el nombre de caràcters que MIDB retornarà del text, en bytes.

Exemple

=MIDB("中国";1;0) returns "" (0 bytes is always an empty string).

=MIDB("中国";1;1) returns " " (1 byte is only half a DBCS character and therefore the result is a space character).

=MIDB("中国";1;2) returns "中" (2 bytes constitute one complete DBCS character).

=MIDB("中国";1;3) returns "中 " (3 bytes constitute one and a half DBCS character; the last byte results in a space character).

=MIDB("中国";1;4) returns "中国" (4 bytes constitute two complete DBCS characters).

=MIDB("中国";2;1) returns " " (byte position 2 is not at the beginning of a character in a DBCS string; 1 space character is returned).

=MIDB("中国";2;2) returns " " (byte position 2 points to the last half of the first character in the DBCS string; the 2 bytes asked for therefore constitutes the last half of the first character and the first half of the second character in the string; 2 space characters are therefore returned).

=MIDB("中国";2;3) returns " 国" (byte position 2 is not at the beginning of a character in a DBCS string; a space character is returned for byte position 2).

=MIDB("中国";3;1) returns " " (byte position 3 is at the beginning of a character in a DBCS string, but 1 byte is only half a DBCS character and a space character is therefore returned instead).

=MIDB("中国";3;2) returns "国" (byte position 3 is at the beginning of a character in a DBCS string, and 2 bytes constitute one DBCS character).

=MIDB("office";2;3) returns "ffi" (byte position 2 is at the beginning of a character in a non-DBCS string, and 3 bytes of a non-DBCS string constitute 3 characters).

MIG

Retorna la cadena de text d'un text. Els paràmetres indiquen la posició inicial i el nombre de caràcters.

Sintaxi

MIG("Text"; Inici; Nombre)

Text és el text que conté els caràcters que s'han d'extreure.

Inici és la posició del primer caràcter del text que s'ha d'extreure.

Nombre indica el nombre de caràcters que conté la part del text.

Exemple

=MIG("oficina";2;2) retorna fi.

MINUSC

Converteix totes les majúscules d'una cadena de text en minúscules.

Sintaxi

MINUSC("Text")

Text es refereix al text que s'ha de convertir.

Exemple

=MINUSC("Sun") retorna sun.

MONEDA

Converts a number to a string representing the amount in the currency format, rounded to a specified decimal places, using the decimal separator that corresponds to the current locale setting. In the Value field enter the number to be converted. Optionally, you may enter the number of decimal places in the Decimals field. If no value is specified, all numbers in currency format will be displayed with two decimal places.

Heu de definir el format de la moneda en la configuració del sistema.

Sintaxi

DOLLAR(Value [; Decimals])

Valor és un nombre, una referència a una cel·la que conté un nombre o una fórmula que retorna un nombre.

Decimals és el nombre opcional de xifres decimals.

Exemple

=DOLLAR(255) returns $255.00 for the English (USA) locale and USD (dollar) currency; ¥255.00 for the Japanese locale and JPY (yen) currency; or 255,00 € for the German (Germany) locale and EUR (euro) currency.

=DOLLAR(367.456;2) returns $367.46.

NETEJA

S'eliminen de la cadena tots els caràcters no imprimibles.

Sintaxi

NETEJA("Text")

Text fa referència al text del qual s'han d'eliminar els caràcters no imprimibles.

Exemple

=LEN(CLEAN(CHAR(7) & "LibreOffice Calc" & CHAR(8))) returns 16, showing that the CLEAN function removes the non-printable Unicode U+0007 ("BEL") and U+0008 ("BS") characters at the beginning and end of the string argument. CLEAN does not remove spaces.

REEMPLAÇA

Reemplaça una part d'una cadena de text per una altra cadena de text. Aquesta funció es pot utilitzar per reemplaçar caràcters i nombres (que es converteixen en text automàticament). El resultat de la funció sempre es mostra en forma de text. Si voleu fer més càlculs amb un nombre que s'ha reemplaçat per text, l'haureu de tornar a convertir en un nombre mitjançant la funció VALOR.

Qualsevol text que contingui nombres s'ha de posar entre cometes perquè no s'interpreti com a nombre i es converteixi automàticament en text.

Sintaxi

REEMPLAÇA("Text"; Posició; Longitud; "TextNou")

Text fa referència al text del qual es reemplaçarà una part.

Posició fa referència a la posició en el text on començarà el reemplaçament.

Longitud és el nombre de caràcters de Text que s'han de reemplaçar.

TextNou fa referència al text que reemplaça Text.

Exemple

=REEMPLAÇA("1234567";1;1;"444") retorna "444234567". Es reemplaça un caràcter en la posició 1 pel TextNou complet.

REPT

Repeteix una cadena de caràcters en funció del nombre de còpies indicat.

Sintaxi

REPT("Text"; Nombre)

Text és el text que s'ha de repetir.

Nombre és el nombre de repeticions.

Exemple

=REPT("Bon dia";2) retorna Bon diaBon dia.

tip

Refer to the REPT wiki page for more details about this function.


RETALLA

Elimina espais d'una cadena; deixa un sol espai entre les paraules.

Sintaxi

RETALLA("Text")

Text fa referència al text de què s'eliminen els espais.

Exemple

=TRIM(" hello world ") returns hello world without leading and trailing spaces and with single space between words.

RIGHTB

Retorna l'últim caràcter o caràcters d'un text amb jocs de caràcters de byte doble (DBCS).

tip

Aquesta funció és disponible des de la versió 4.2 del LibreOffice.


Sintaxi

RIGHTB("Text" [; Number_bytes])

Text és el text del qual es determinarà la part dreta.

Number_bytes (optional) specifies the number of characters you want RIGHTB to extract, based on bytes. If this parameter is not defined, one byte is returned.

Exemple

DRETAB("中国";1) retorna " " (1 byte només és la meitat d'un caràcter DBCS i, per tant, es retorna un espai).

DRETAB("中国";2) retorna "国" (2 bytes formen un caràcter DBCS complet).

DRETAB("中国";3) retorna "国 " (3 bytes formen un caràcter DBCS i mig i un caràcter DBCS complet; es retorna un espai per la primera meitat).

DRETAB("中国";4) retorna "中国" (4 bytes formen dos caràcters DBCS complets).

DRETAB("Àngel";3) retorna «gel» (3 caràcters no-DBCS, cadascun format per 1 byte).

SUBSTITUEIX

Reemplaça text vell per text nou en una cadena.

Sintaxi

SUBSTITUTE("Text"; "SearchText"; "NewText" [; Occurrence])

Text és el text en el qual s'han d'intercanviar segments de text.

TextDeCerca és el segment de text que s'ha de reemplaçar (un nombre de vegades).

TextNou és el text que ha de reemplaçar el segment de text.

Aparició (opcional) indica quina aparició del text de cerca s'ha de reemplaçar. Si manca aquest paràmetre, es reemplaça el text de cerca arreu.

Exemple

=SUBSTITUEIX("123123123";"3";"abc") retorna 12abc12abc12abc.

=SUBSTITUEIX("123123123";"3";"abc";2) retorna 12312abc123.

T

Aquesta funció retorna el text de destinació o, si la destinació no és text, retorna una cadena de text buida.

Sintaxi

T(Valor)

Si Valor és una cadena de text o fa referència a una cadena de text, T retorna aquesta cadena de text; altrament, retorna una cadena de text buida.

Exemple

=T(12345) retorna una cadena buida.

=T("12345") retorna la cadena 12345.

TEXT

Converts a value into text according to a given format.

Sintaxi

TEXT(Value; Format)

Value is the value (numerical or textual) to be converted.

Format és el text que defineix el format. Utilitzeu els decimals i els separadors de milers en funció de la llengua indicada en el format de cel·la.

Exemple

=TEXT(12,34567;"###,##") retorna el text 12,35.

=TEXT(12,34567;"000,00") retorna el text 012,35.

=TEXT("xyz";"=== @ ===") retorna el text === xyz ===

tip

Vegeu també Codis de format numèric: codis de format personalitzats definits per l'usuari.


TEXTBAHT

Converteix un nombre en text thai, incloent-hi els noms de moneda thai.

Sintaxi

TEXTBAHT(Nombre)

Nombre és qualsevol nombre. S'afegeix "baht" a la part entera del nombre i "satang" a la part decimal.

Exemple

=TEXTBAHT(12,65) retorna una cadena en caràcters thai amb el significat de "Dotze baht i seixanta-cinc satang".

Informació tècnica

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

COM.MICROSOFT.BAHTTEXT

TROBA

Retorna la posició d'una cadena de text en una altra cadena. També podeu definir on voleu començar la cerca. El terme de cerca pot ser un nombre o qualsevol cadena de caràcters. En la cerca es distingeix entre majúscules i minúscules.

Sintaxi

FIND("FindText"; "Text" [; Position])

TextDeCerca és el text que s'ha de cercar.

Text és el text on es du a terme la cerca.

Posició (opcional) és la posició en el text des d'on comença la cerca.

Exemple

=TROBA(76;998877665544) retorna 6.

UNICODE

Retorna el codi numèric del primer caràcter Unicode d'una cadena de text.

Sintaxi

UNICODE("Text")

Exemple

=UNICODE("©") retorna el nombre Unicode 169 corresponent al caràcter de copyright.

tip

Vegeu també la funció CARACUNI().


Ens cal la vostra ajuda!