Contact

CLEAN Function in ONLYOFFICE Spreadsheet Editor: Syntax and Examples

Text and Data Beginner ONLYOFFICE Spreadsheet Editor

Remove nonprinting characters from imported text; preserve a separate copy of the original value for auditing.

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

CLEAN removes nonprinting characters from text. For the explicit input ="AB"&CHAR(13)&"CD", the expected cleaned text is ABCD. The separator is removed, not replaced with a space, so cleaning can join words or identifiers.

Availability and version history

  • Introduced: The original introduction version and date are not established by the checked references.
  • Availability: Documented in current ONLYOFFICE Spreadsheet Editor help; no final supported-version endpoint is established.
  • Scope: Desktop and Docs release separately. Older builds, mobile clients, localized parsing and imported-workbook parity remain separately unverified.
  • Checked: October 14, 2026, against the official CLEAN reference, vendor illustrations and pinned calculation source. The explicit text examples were independently calculated; these formulas were not executed in a native application.

Syntax and the scope of cleaning

CLEAN(text)

The official reference takes one required text argument. Its short description does not enumerate every Unicode character. The pinned calculation source retains string units above hexadecimal 1F and removes units 0–31. That source evidence supports the ordinary tab, line-feed and carriage-return examples here; it does not establish every installed build or make CLEAN a general-purpose security sanitizer.

The vendor illustration shows =CLEAN(A1) returning text from an input with a visible nonprinting-character marker. The image does not identify the marker’s exact stored code, so it is insufficient to reconstruct that input byte-for-byte. The worksheet below instead generates specified controls with CHAR.

Recreate the original five inputs

Create ImportedText, reserving A1:J10. Put Imported value in A1. Enter these inputs exactly; formulas must start with = so the control characters are generated rather than displayed as formula text.

Cell Input
A2 =CHAR(9)&"Invoice-104"&CHAR(10)
A3 Literal North with two ordinary spaces before and two after
A4 ="AB"&CHAR(13)&"CD"
A5 ="SKU-77"&CHAR(9)
A6 ="alpha"&CHAR(10)&"beta"

The codes 9, 10 and 13 represent the conventional ASCII tab, line feed and carriage return. For A3, type two space characters, North, then two spaces; do not type quote marks or a visible space symbol.

Enter the original outputs as follows:

Cell Formula Expected result
B2 =CLEAN(A2) Invoice-104
B3 =CLEAN(A3) two spaces + North + two spaces
B4 =CLEAN(A4) ABCD
B5 =LEN(CLEAN(A5)) number 6
B6 =CLEAN(A6) alphabeta

B5 intentionally contains a length, not cleaned text. Do not fill one common B formula over that original result. Put =CLEAN(A5) in D5 if you want to see the separate cleaned identifier SKU-77.

Make invisible changes measurable

Use F1:I1 for Original length, Cleaned length, Removed count and Cleaned text. Enter these formulas in row 2, then fill F2:I2 through row 6:

F2: =LEN(A2)
G2: =LEN(CLEAN(A2))
H2: =F2-G2
I2: =CLEAN(A2)
Row Expected F G H I
2 13 11 2 Invoice-104
3 9 9 0 two spaces + North + two spaces
4 5 4 1 ABCD
5 7 6 1 SKU-77
6 10 9 1 alphabeta

LEN counts the ordinary control characters as part of these input strings. The removed count identifies a change, but does not decide whether that change is acceptable.

Keep comparison and space trimming separate

Put literal SKU-77 in C5. In D2 enter =EXACT(A5,C5) for FALSE and in D3 enter =EXACT(CLEAN(A5),C5) for TRUE. The raw tab makes the first strings different. EXACT compares the transformed text only when CLEAN is explicitly included.

In D6 enter =TRIM(CLEAN(A3)) for North, with D7 =LEN(D6) returning 5. CLEAN alone preserves A3’s four printable spaces, as G3=9 confirms. TRIM is a separate choice for leading/trailing ordinary spaces.

Advanced: decide whether a line break represents a separator

Create LineBreakPolicy, reserving A1:F8. Put Original, Cleaned, Replace break first, Raw length, Cleaned length and Replaced length in A1:F1. Enter these formulas in A2:A4:

  • A2: ="alpha"&CHAR(10)&"beta"
  • A3: ="alpha beta"
  • A4: ="alphabeta"

Enter B2 =CLEAN(A2), C2 =CLEAN(SUBSTITUTE(A2,CHAR(10)," ")), D2 =LEN(A2), E2 =LEN(B2) and F2 =LEN(C2). Fill B2:F2 through row 4.

Row Expected B C D E F
2 alphabeta alpha beta 10 9 10
3 alpha beta alpha beta 10 10 10
4 alphabeta alphabeta 9 9 9

SUBSTITUTE replaces all occurrences when its optional instance argument is omitted. Here it deliberately converts only line feed to an ordinary space before cleaning. It is not a universal rule for every imported control sequence.

In B6 enter =EXACT(B2,B4) for TRUE: two different original inputs collapse to the same cleaned result. C6 =EXACT(C2,C3) also gives TRUE, under the explicitly different separator policy. D6 =EXACT(A2,A4) gives FALSE, preserving the fact that the originals differ.

Copy LineBreakPolicy as CarriageReturnCase and change only A2 to ="alpha"&CHAR(13)&"beta". B2 and C2 now both have the expected value alphabeta, with D2:F2 10,9,9. The replacement formula targets CHAR(10), so it does not insert a space for CHAR(13); CLEAN subsequently removes that control. Choose rules based on the actual input contract.

Limits and troubleshooting

Ordinary spaces are printable; CLEAN is not a substitute for a trimming policy. Nonbreaking spaces, zero-width characters and other Unicode inputs require separately established behavior. Do not assume every invisible character belongs to the ASCII 0–31 set.

Keep original imports, transformations and comparison results in distinct columns. If records become equal after cleaning, investigate whether they genuinely represent the same item before deduplicating them. Nested errors, numeric/date conversion, arrays and client-specific import/export behavior remain outside these explicit text examples.