LEFTB Function (LibreOffice Calc)
Learn the LEFTB function in LibreOffice Calc: Returns the first character or characters of a text, with DBCS.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in LibreOffice Calc. How formula examples are checked
Validation scope: References to observed, native-tested, or executed results below describe the saved LibreOffice Calc 25.2.3.2 Linux test evidence dated 12 October 2026. On 13 October, its script and artifact hashes, all 86 ODS/JSON case pairs, and the current official function documentation were checked; CJK/ASCII worked examples were independently reasoned through. Calc was not rerun for this review. Historical observations do not certify other versions, platforms, locales, or workbook imports.
LEFTB takes a specified number of DBCS-style byte units from the beginning of a string. Unlike LEFT, it can replace a partial double-byte character with an ordinary space. This matters when examining legacy fixed-width or double-byte text and when comparing Calc to other spreadsheet engines.
Function purpose: byte-width prefix versus character prefix
Use LEFT when you mean a number of characters. Use LEFTB only when a DBCS-oriented byte-width limit is appropriate. The difference is visible with CJK characters. =LEFT("中国";1) selects the first character, 中; =LEFTB("中国";1) instead returned one plain space in the tested Calc environment because one byte cannot hold a complete two-byte character. [LO-LEFTB] [NATIVE]
The blank-looking result is not necessarily an empty string. The official Calc Help states that incomplete DBCS characters are represented using a space. This is a critical limitation if you intend to validate identifiers or remove whitespace later: the space is now part of the returned text. [LO-LEFTB]
Syntax, parameter order, and defaults
=LEFTB(Text [; Number_bytes])
| Argument | Required | Meaning | Default |
|---|---|---|---|
Text |
Yes | Literal text, a cell reference, or an expression converted to text. | No default; omission is invalid. |
Number_bytes |
No | How many DBCS byte units to extract from the left. Fractions were truncated in native tests. | 1 byte if omitted (shown by the official examples and the test results). |
LibreOffice’s Help labels this as available since 4.2. The English name is LEFTB. Calc commonly uses ; between arguments, while English function names and separators are configurable under Tools → Options → LibreOffice Calc → Formula. A localized function display may differ; do not infer that an Excel comma-separated formula uses identical syntax in Calc. No separate ODF-specific alias was verified for this function. [LO-LEFTB] [LO-OPTIONS] [NATIVE]
Reproducible examples
The following results were executed in LibreOffice Calc 25.2.3.2. A ␠ denotes one ordinary ASCII space (U+0020) in the output, not an empty string; literal strings are shown inside double quotes for clarity.
| Formula | Observed string | Explanation |
|---|---|---|
=LEFTB("office";3) |
"off" |
Three Latin characters, each one unit. |
=LEFTB("中国";1) |
"␠" |
Half of the first two-byte character → one space. |
=LEFTB("中国";2) |
"中" |
Exactly one complete DBCS character. |
=LEFTB("中国";3) |
"中␠" |
Second character is incomplete → trailing space. |
=LEFTB("中国";4) |
"中国" |
Entire string. |
=LEFTB("中国") |
"␠" |
Omitted byte count defaults to 1. |
=LEFTB("中国";0) |
"" |
Zero-byte request → empty result. |
=LEFTB("中国";5) |
"中国" |
A request longer than the input returns all text. |
The documentation supplies the CJK/ASCII base cases; the additional zero, default, and out-of-range cases were independently checked in the native workbook. Do not replace the displayed space with a missing cell value when copying an output into another formula. [LO-LEFTB] [NATIVE]
Mixed text: a prefix that ends on a partial character
Consider the string A中B: A consumes one DBCS unit, 中 consumes two and B consumes one, for a total of four units in the tested engine. [NATIVE]
| Formula | Result | Why |
|---|---|---|
=LEFTB("A中B";1) |
"A" |
First ASCII byte. |
=LEFTB("A中B";2) |
"A␠" |
Second requested unit is only half of 中. |
=LEFTB("A中B";3) |
"A中" |
Three units include the full Chinese character. |
=LEFTB("A中B";4) |
"A中B" |
All four units. |
These four formulas were all native-tested in LibreOffice Calc 25.2.3.2. LEFTB is not equivalent to slicing raw bytes from a UTF-8 file and decoding the result. Its replacement-space behavior can affect exact-string comparisons. [NATIVE] [LO-LEFTB]
Follow along with a cell reference
Enter 中A in J2, then enter:
=LEFTB(J2;3)
Native-tested output: 中A. A budget of three covers the two-unit ideograph plus one-unit Latin suffix. With =LEFTB("中A";1), Calc returned a single space instead, not 中. [NATIVE]
Advanced patterns
Validate a stable ASCII prefix
If a legacy identifier must start with two ASCII letters, use a comparison that does not depend on slicing inside CJK characters:
=IF(LEFTB("AB中";2)="AB";"OK";"CHECK")
Observed: OK in native Calc. For ordinary text identifiers not governed by a DBCS byte specification, the character-counting LEFT is simpler and avoids partial-character spaces. [NATIVE]
Build extraction with LENB
The pair LENB and LEFTB uses related DBCS semantics, but LENB(LEFTB(...)) measures the returned text, which may contain substitution spaces. For example, =LEFTB("A中B";2) returned A␠ (the second unit is a replacement space). A downstream validator must not mistake that space for the original Chinese character. This is a native-observed behavior plus a logical consequence; the nested length is not separately reported as an executed assertion here. [NATIVE]
Decimal counts, numeric text, and Unicode boundaries
=LEFTB("中国";2.9) returned 中; =LEFTB("中国";1.9) returned a space. This indicates truncation to an integer in Calc 25.2.3.2, not rounding. =LEFTB(12345;3) returned 123 because numeric input was rendered as text in that setup. Non-BMP Unicode characters and combining sequences may behave differently from DBCS-era expectations; do not use LEFTB as a general-purpose Unicode-safe truncator. Results in other locales/versions require fresh validation. [NATIVE]
Troubleshooting and error cases
| Formula/problem | Observed Calc 25.2.3.2 result | Action |
|---|---|---|
=LEFTB("中国";-1) |
Err:502 |
Use a nonnegative count. |
=LEFTB("中国";"abc") |
#VALUE! |
Supply a numeric count. |
=LEFTB() |
Err:511 |
Provide required Text. |
=LEFTB("a";1/0) |
#DIV/0! |
Fix the upstream calculation. |
| Chinese text becomes a space | Expected when extracting an incomplete DBCS character. | Increase the byte budget to cover the complete character, or use LEFT instead. |
| Formulas work only with commas on another machine | Formula separator setting differs. | Confirm Calc’s Formula settings. |
The codes are observations of the tested native build, not a cross-version guarantee. A formula that returns a space may look blank: test with LEN or put delimiters around the result to reveal it. That final troubleshooting suggestion was not separately native-executed for the saved test. [NATIVE] [LO-OPTIONS]
Cross-application compatibility
LibreOffice Calc officially supports LEFTB from version 4.2, and Google Sheets documents its own LEFTB(string, num_of_bytes) with comma-separated examples. Microsoft’s current LEFT documentation states that LEFTB is deprecated in Excel. These are documentation-only comparisons; the saved test executed formulas in LibreOffice only. Do not promise identical Unicode, locale, or edge-case behavior in Google Sheets or Excel based merely on the shared name. [LO-LEFTB] [GOOGLE-LEFTB] [MS-LEFT]
Related function guides
Sources and verification records
Every documentation source below was accessed 2026-10-12. “Latest” LibreOffice Help displayed 26.8; executable native testing used 25.2.3.2 on Linux.
- [LO-LEFTB] LibreOffice official LEFTB Help: availability, syntax, byte count, replacement-space examples.
- [LO-OPTIONS] LibreOffice Calc Formula Options: function localization and configurable separators.
- [GOOGLE-LEFTB] Google Sheets LEFTB documentation: name, syntax and broad purpose, not native-tested in the saved test.
- [MS-LEFT] Microsoft Excel LEFT documentation: LEFTB deprecation notice; not native-tested here.
- [NATIVE] Saved LibreOffice Calc 25.2.3.2 Linux test records dated 2026-10-12. The preserved script, ODS cached results, and per-formula results agree for the cited cases. This review did not rerun Calc.