LEFT Function in ONLYOFFICE Spreadsheet Editor: Syntax and Worked Examples
Use LEFT and LEFTB 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
LEFT takes characters from the beginning of a string. For CA-ON-1047, taking two characters gives text CA; taking five gives CA-ON, including its separator. The original cell stays unchanged.
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 LEFT reference, vendor illustration and pinned calculation source. ASCII examples were independently calculated; no native execution of these extraction formulas was performed.
Syntax, default and zero-length results
LEFT(text, [num_chars])
The official reference requires the source text. The optional count must be nonnegative and defaults to 1 when omitted. Brackets describe optional syntax; do not type them.
The pinned source takes the requested leading substring. For an explicit zero count this yields empty text; that is a source-backed expectation, not a new native observation. A blank-looking formula result is different from a cell containing no formula.
To reproduce the vendor illustration, create VendorLeft, enter Online Office in A1 and put =LEFT(A1,6) in C1. The expected result is Online. Its six letters precede the space separating the two words.
Enter the original code examples
Create PrefixCodes, reserving A1:H12. Put Code in A1 and type the following strings as text:
| Cell | Code |
|---|---|
| A2 | CA-ON-1047 |
| A3 | US-NY-0052 |
| A4 | CA-BC-0318 |
| A5 | CA-ON-1048 |
| A6 | US-CA-2004 |
| A7 | BADCODE |
The first five use country, region and serial fields separated by two hyphens. BADCODE deliberately lacks the separators. The leading zeroes in 0052 and 0318 remain part of the original identifiers.
Use these separate result cells for the original basic examples:
| Cell | Formula | Expected text |
|---|---|---|
| C2 | =LEFT(A2,2) |
CA |
| C3 | =LEFT(A3,2) |
US |
| C4 | =LEFT(A4,5) |
CA-BC |
| C5 | =LEFT(A2) |
C |
| C6 | =LEFT(A2,0) |
empty text |
C4 requests a different count intentionally. Do not replace it by filling a two-character formula down the entire column if you want to retain that original example.
Extract the first field and keep the raw error visible
Put =LEFT(A2,FIND("-",A2)-1) in D2 and fill through D7. FIND locates the first hyphen. Subtracting one supplies the number of preceding characters.
In E2 put =IFERROR(D2,"Check code") and fill through E7. This keeps the raw calculation and guarded result in separate columns:
| Row | Expected D | Expected E |
|---|---|---|
| 2 | CA | CA |
| 3 | US | US |
| 4 | CA | CA |
| 5 | CA | CA |
| 6 | US | US |
| 7 | #VALUE! | Check code |
The documented FIND no-match error explains D7. IFERROR returns its fallback for that error. Do not overwrite D7 with the guarded formula if you want to inspect why the row failed.
For the original all-in-one guard, put this formula in G7:
=IFERROR(LEFT(A7,FIND("-",A7)-1),"Check code")
Its expected result is also Check code. Error handling is useful for presentation, but it can conceal unrelated formula or reference errors as well as missing delimiters.
Advanced: a longer first field changes fixed extraction
Create VariablePrefix, reserving A1:F7. Put Code in A1 and enter CA-ON-1047, CAN-ON-1047 and CAB-ON-1047 in A2:A4.
Enter =LEFT(A2,2) in C2, =LEFT(A2,FIND("-",A2)-1) in D2 and =EXACT(C2,D2) in E2. Fill C2:E2 through row 4.
| Row | Expected C | Expected D | Expected E |
|---|---|---|---|
| 2 | CA | CA | TRUE |
| 3 | CA | CAN | FALSE |
| 4 | CA | CAB | FALSE |
The fixed extraction makes all three strings look alike. The delimiter-based calculation preserves the complete first field. EXACT compares the two strings without assuming that a shared prefix means an identical identifier.
Neither calculation checks whether CAN or CAB is an approved code. Validate permitted field values separately rather than treating successful extraction as approval.
Leading spaces and practical boundaries
On a new LeadingSpace sheet, enter =" CA-ON-1047" in A2, with one leading space inside the quotes. Put =LEFT(A2,2) in B2 for expected space+C. Put =LEFT(A2,FIND("-",A2)-1) in C2 for expected space+CA. The delimiter method preserves the leading space too; it does not silently clean the input.
A negative count violates the documented domain. Fractional counts, numeric/date source conversion, existing errors and special Unicode are outside these native-untested examples. The reference separately describes LEFTB for byte-based language scenarios; its documentation does not establish that character and byte counts are interchangeable.
RIGHT selects from the other end, while MID starts at a chosen position. The formulas here use ordinary ASCII text and English comma separators. Check the target workbook’s formula language and notation before reusing them.
LEFTB: documented byte-oriented variant
LEFTB(text, [num_bytes])
The text argument is required. num_bytes is optional; the inspected inherited calculation supplies 1 when omitted. The help describes this count in bytes, which is distinct from proof of the installed calculation.
Documentation and implementation are different evidence
The official LEFT/LEFTB reference describes LEFTB for byte-oriented or double-byte-character-set language use. However, the pinned LEFTB implementation directly inherits LEFT, 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 LEFTB
On a separate LeftbControls 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 |
|---|---|---|
=LEFTB("ORD-4821",3) |
ORD | The three-position prefix is ORD. |
=LEFTB("ORD-4821",4) |
ORD- | The fourth position includes the hyphen. |
=LEFTB("ORD-4821",0) |
empty text | Zero positions yield empty text. |
=LEFTB("ABC") |
A | The inherited default is one. |
=LEFTB("ABC",20) |
ABC | The requested count extends past the available text. |
=LEFTB("ABC",-1) |
#VALUE! | The inherited calculation rejects a negative count. |
Taking four positions from ORD-4821 includes the hyphen; taking three excludes it. A fixed prefix length is a layout assumption, so compare delimiter positions if codes have different prefix lengths.
Migrating a workbook that uses LEFTB
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 LEFTB with LEFT 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.