Contact

TRIM Function (OpenOffice Calc)

Text Intermediate OpenOffice Calc

Learn the TRIM function in Apache OpenOffice Calc: Removes extra spaces from text.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Availability and version history

  • Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
  • Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
  • Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
  • Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.

TRIM removes leading and trailing ordinary spaces and collapses runs of ordinary spaces between words to one space. It is useful for imported labels, but it is not a universal removal tool for tabs, line breaks or every Unicode whitespace character.

Syntax and arguments

=TRIM(text)

text is the one required string or reference. There is no switch to preserve internal runs while trimming the ends. The pinned 4.1.16 interpreter explicitly checks ordinary space characters in its internal-collapse loop. Define which characters need cleaning before applying the function broadly. The formulas use English function names and Calc’s semicolon argument separator.

Reproducible examples

Formula Expected text or number
=TRIM(" one two ") "one two"
=TRIM("hello") "hello"
=TRIM(" A ") "A"
=TRIM("a b") "a b"
=TRIM(" ") ""
=TRIM("") ""

Here "" denotes zero-length text, not a displayed pair of quotation marks. The first example retains the original guide’s formula. Its comparable LibreOffice 25.2 result was not an OpenOffice test; the new examples are expected results derived from the documented operation and independently checked text mappings.

Practical worksheet: clean imported category labels

Enter North, South and West Region in A2:A4, preserving the displayed ordinary spaces. In B2 enter =TRIM(A2) and fill down. Expected results are North, South and West Region. Keep column A so you can compare the transformation against the imported data.

In C2 enter =LEN(A2)-LEN(B2) and fill down. Expected counts of removed characters are 2, 2 and 2. In D2 enter =EXACT(A2;B2) and fill down; all three rows are FALSE because their strings changed. A row with East and no extra spaces would remain unchanged.

Advanced applications

Clean and standardize case. =UPPER(TRIM(A2)) returns NORTH for north . This combines two deliberate rules. TRIM itself leaves case unchanged.

Handle a known nonbreaking space. When inspection confirms U+00A0 characters and the policy permits treating them as word spaces, =TRIM(SUBSTITUTE(A2;UNICHAR(160);" ")) replaces those characters with ordinary spaces before trimming. This targeted transformation is not a promise that every invisible character is removed. Preserve the original and validate mixed-language data.

Detect an empty cleaned result. =LEN(TRIM(A2))=0 is TRUE for an empty string or a string made only of ordinary spaces. It asks whether the cleaned text is empty, whereas ISBLANK asks whether a referenced cell actually contains nothing. A formula returning empty text is not a genuinely empty cell.

Errors, edge cases and troubleshooting

TRIM changes internal spacing. It is unsuitable for fixed-width records, aligned text, passwords or identifiers in which repeated spaces matter unless the specification explicitly allows that change.

If spaces seem to survive, inspect their character codes rather than repeatedly nesting TRIM. A nonbreaking space, tab and ordinary space may look similar. CLEAN has a different remit and should not be assumed to erase all Unicode formatting characters either.

TRIM does not validate numeric text or choose its decimal separator. It can prepare a string for a later conversion, but VALUE may still fail or interpret locale-sensitive punctuation differently. A blank-looking result may be zero-length text; it is not evidence that the source cell is empty.

For a list of records, enter a scalar helper formula in the first result row and fill down. Check the absolute and relative references before copying. Do not assume that a single multi-cell argument automatically produces a modern spill range in OpenOffice Calc.

Documentation and verification

See the Apache OpenOffice TRIM reference, 4.1.16 text-function help, and versioned interpreter. The source snapshots were originally retrieved on 2026-10-13 and re-read for this revision. Independent text calculations are not native application or GUI tests. Current support is version-scoped above; introduction and final functioning version remain unestablished.