Contact

LEN Function in ONLYOFFICE Spreadsheet Editor: Syntax and Worked Examples

Text and Data Beginner ONLYOFFICE Spreadsheet Editor

Use LEN and LENB in ONLYOFFICE with worked ASCII examples and clear byte-contract, source and migration cautions.

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

=LEN(A2) has the expected result 10 when A2 contains CA-ON-1047. Both hyphens count. LEN measures a text sequence’s length; it does not determine whether the identifier is meaningful or valid.

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 LEN 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 character-count scope

LEN(text)

The official reference takes one required text value or reference. Spaces and punctuation are part of the text. These examples use plain ASCII so each displayed character corresponds to one counted position.

The same help page distinguishes LEN from the byte-oriented LENB. It does not establish how every client handles emoji, combining marks or byte-oriented calculations. The checked LEN source measures the converted string’s length; that is not a promise to count user-perceived Unicode characters or screen width.

On VendorLength, enter Online Office in A1 and =LEN(A1) in C1. The official illustration shows 13: six characters, one space and six more characters.

Build the original six-code worksheet

Create CodeLengths, reserving A1:H12. Put Code in A1, Length in C1, Hyphens in D1 and Shape check in E1. Enter these values as text in A2:A7:

Row Code
2 CA-ON-1047
3 US-NY-0052
4 CA-BC-0318
5 CA-ON-1048
6 US-CA-2004
7 BADCODE

Put =LEN(A2) in C2 and fill through C7. Expected results are 10,10,10,10,10,7. For the first code, the components have lengths 2+1+2+1+4=10. The leading zeros inside the complete text codes remain characters.

Use G2 =LEN("") for 0 and G3 =LEN("A B") for 3. G2 is an explicit empty text argument, not an assertion about all types of empty-looking worksheet cells.

Count delimiters without changing the original

In D2 enter =LEN(A2)-LEN(SUBSTITUTE(A2,"-","")) and fill through D7. The expected counts are 2,2,2,2,2,0.

SUBSTITUTE replaces every occurrence when its optional occurrence number is omitted. Here the replacement is empty text, so each removed single-character hyphen reduces length by one. The original A values remain untouched.

This length difference counts characters removed. If the search token were two characters long, it would not directly equal the number of nonoverlapping token occurrences without adjusting for that token’s length.

Combine length and separator positions

Put =AND(LEN(A2)=10,MID(A2,3,1)="-",MID(A2,6,1)="-") in E2 and fill through E7. Expected results are TRUE,TRUE,TRUE,TRUE,TRUE,FALSE.

MID inspects positions 3 and 6. AND requires all three conditions. This lightweight shape rule does not check whether country/region codes are authorized or the final four characters are digits.

Advanced: show the difference between length and validation

Create ShapeControls, reserving A1:F10. Put Candidate, Length, Hyphens, Shape and Length only in A1:E1. Enter the following text in A2:A6. A5 has one leading ordinary space; A6 has one trailing ordinary space. The visible ␠ below is explanatory, not a character to type.

Row Candidate
2 CA-ON-1047
3 CA-ON-ABCD
4 CA_ON_1047
5 ␠CA-ON-1047
6 CA-ON-1047␠

Enter B2 =LEN(A2), C2 =LEN(A2)-LEN(SUBSTITUTE(A2,"-","")), D2 =AND(B2=10,MID(A2,3,1)="-",MID(A2,6,1)="-") and E2 =B2=10. Fill B2:E2 through row 6.

Row Expected B C D E
2 10 2 TRUE TRUE
3 10 2 TRUE TRUE
4 10 0 FALSE TRUE
5 11 2 FALSE FALSE
6 11 2 FALSE FALSE

Row 3 deliberately passes despite its alphabetic serial. Row 4 passes a length-only rule despite having the wrong separators. A clean-looking length is therefore one diagnostic, not a complete identifier policy.

Copy ShapeControls as ShortSerial and change only A2 to CA-ON-7. B2:E2 becomes 7,2,FALSE,FALSE. The two delimiters remain, but the serial width changes. Preserve the original sheet so a changed record is not confused with a formula defect.

Inspect spaces before deciding to remove them

On the original CodeLengths sheet, G5 =LEN(" CA-ON-1047") and G6 =LEN("CA-ON-1047 ") both return 11. G7 =LEN(TRIM(" CA-ON-1047 ")) has the expected result 10 under the documented leading/trailing-space rule of TRIM.

Trimming is a separate transformation. It may be appropriate for accidental padding but should not silently redefine an identifier whose spaces are meaningful. LEN can reveal a difference without choosing a cleanup policy.

Limits and troubleshooting

The fixture uses stored text, not formatted dates or numbers. A cell’s displayed numeric width does not establish the string LEN will measure after coercion. Real blanks, errors, arrays, multilingual text and client-specific conversions remain outside these calculations.

Check that copied formulas still refer to the intended row. If two strings have equal lengths but different contents, EXACT can compare their case-sensitive identity. FIND can inspect delimiter locations. Neither length nor successful extraction proves that a code appears in an approved register.

LENB: documented byte-oriented variant

LENB(text)

One text argument is required. The documented role is a byte-oriented length. The inherited LEN calculation measures its converted string length; it is not an encoding-size calculation.

Documentation and implementation are different evidence

The official LEN/LENB reference describes LENB for byte-oriented or double-byte-character-set language use. However, the pinned LENB implementation directly inherits LEN, without a separate calculation override in that definition. This is a documented-contract versus inspected-implementation discrepancy, not proof that all clients implement a separate DBCS byte algorithm.

The added coverage was checked on October 19, 2026. Neither the first supported version nor a last supported version is established. The source revision is evidence about that revision, not native execution, a universal Unicode rule or cross-version compatibility.

Worked ASCII controls for LENB

On a separate LenbControls sheet, enter the following formulas into individual empty cells. They contain their inputs, so they do not overwrite the earlier worksheets. Results are independently reasoned from ordinary ASCII and the inherited calculation, not observations from a running ONLYOFFICE editor. Text results remain text; “empty text” means a formula result of zero length.

Formula Expected result Explanation
=LENB("ORD-4821") 8 Three letters, a hyphen and four digits total 8.
=LENB("A B") 3 The internal space counts as one position.
=LENB("") 0 The explicit empty string has zero length.

ORD-4821 has three letters, one hyphen and four digits. The space in A B counts too. Empty text has length zero in this source model; this control says nothing about every blank-looking cell or formatted number.

Migrating a workbook that uses LENB

Keep a copy of the original formula and its source text. Compare the ASCII controls first, then separately check the real workbook’s Japanese, Chinese or Korean text, mixed-script strings, emoji and combining marks in the intended editor/build and locale. Record actual results instead of deriving them from these ASCII examples.

Do not equate the B suffix with UTF-8 file size, display width or user-perceived characters, and do not silently replace LENB with LEN in a workbook whose author depended on byte positions. Matching names and inherited code do not establish import/export parity. Confirm formula separators and language in the destination editor; fractional counts, type conversions and unlisted error cases remain outside this evidence.