Contact

LEFTB Function in OpenOffice Calc

Text Intermediate OpenOffice Calc Apache OpenOffice 4.0

Use LEFTB in OpenOffice Calc to extract a DBCS-counted prefix. Includes mixed CJK examples, split-character spaces, optional length and version history.

Verification status: Official release source and independently calculated examples for LEFTB were reviewed. No new Apache OpenOffice Calc application execution is claimed for this guide; the stated version and example limits still apply. How formula examples are checked

LEFTB takes text from the start of a value using DBCS length units. For example, =LEFTB("東京A";4) returns 東京, while =LEFT("東京A";2) returns the same two characters by a different counting rule.

Availability and version history

  • First introduced: Apache OpenOffice 4.0. The official release notes explicitly list LEFTB among the new DBCS functions.
  • Current status: supported in Apache OpenOffice 4.1.16 desktop Calc, confirmed in the enabled function registry and implementation at the AOO4116-GA release tag.
  • Last supported version: no final version or removal date established. “Supported in 4.1.16” is a checked version, not an endpoint.
  • Platform and locale: desktop Calc; DBCS and system-language details can affect counting. This guide does not claim every platform or Unicode edge case was executed.
  • Test status: Apache OpenOffice native execution has not been performed. The principal mixed-CJK examples were independently reasoned from Apache’s implementation and cross-checked in LibreOfficeDev 26.8.0.0.alpha0 (build 2c87e51eeaa2b413ff4ae097b2705eea1995d8e5). A LibreOffice check is supplementary, not an OpenOffice test.
  • Evidence checked: 2026-10-14.

Sources: Apache OpenOffice 4.0 release notes, LEFTB registry, LEFTB implementation.

Syntax and arguments

LEFTB(Text; [Number])
Argument Required? Meaning
Text Required Text or a cell reference containing text.
Number Optional DBCS units to return from the left; default 1.

These examples use semicolons between arguments and English function names. Enter literal text in double quotes; a cell reference does not need quotes.

Worked example: a prefix in a mixed-language code

  1. Enter 東京A in A2, with no quotation marks.
  2. Enter =LEFTB(A2;4) in B2. The expected result is 東京.
  3. Enter =LEFTB(A2;3) in B3. The expected result is "東 ", with one trailing space.
  4. Enter =LEN(B3) in C3. The expected character count is 2, confirming that the space remains.

The input has DBCS length 5: two units for 東, two for 京 and one for A. The three-unit request includes all of 東 but only part of 京, which is replaced by a space.

Compare the alternatives before choosing a formula

Formula Expected result Reason
=LEFTB("AB東京";2) AB Both Latin characters count as one.
=LEFTB("東京A";4) 東京 Two complete CJK characters need four units.
=LEFTB("東京A";3) "東 " A split CJK character becomes a space.
=LEFTB("東京A") " " Default length 1 splits the first character.
=LEFTB("東京A";0) Empty text Zero units requested.
=LEFTB("東京A";20) 東京A Request exceeds the input’s length.

For a field that allows up to four DBCS units, =LEFTB(A2;4) enforces that unit limit, but it can leave a boundary space. Do not silently add TRIM unless removing leading or trailing spaces is acceptable for that field. For a human-facing two-character abbreviation, use LEFT(A2;2) instead.

What “byte” means here

Calc uses its DBCS text-counting rules: ordinary Latin characters count as one unit and the CJK characters used in these examples count as two. This is not a general UTF-8 file-size calculation. Do not use it to estimate an exported file’s byte length. Use the ordinary character-based function when a requirement is expressed as a number of characters.

A boundary through the middle of a two-unit character produces a space for the incomplete character. The space is part of the returned text and can affect comparisons, concatenation and lookups. In the examples below, quotation marks show the boundaries of returned text; they are not part of the result.

The implementation also has Japanese-system-language handling for the backslash and euro characters. These examples deliberately avoid those locale-sensitive cases. Test representative production text if a workflow depends on a specific language or encoding.

Common errors and practical checks

Negative lengths produce an invalid-argument error. Decimal lengths are floored: a length of 3.9 is treated as 3. A string-length limit also applies; do not pass arbitrarily large counts. Missing text, an error in the input cell or an unsupported older application can fail before extraction.

Before using the result in a lookup or concatenation, compare it with a known small example. Put square brackets around returned text with ="["&B2&"]" when spaces would otherwise be invisible.

LEFT in OpenOffice Calc uses ordinary character positions. The B-suffixed function is a distinct calculation, not a URL alias for that guide.