Contact

MIDB Function in OpenOffice Calc

Text Intermediate OpenOffice Calc Apache OpenOffice 4.0

Use MIDB in OpenOffice Calc with a one-based DBCS position, complete and split-character examples, errors, and version history.

Verification status: Official release source and independently calculated examples for MIDB 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

MIDB extracts a section of text using DBCS positions and lengths. With A東京B, =MIDB("A東京B";2;4) returns 東京: the first CJK character starts at unit 2 and the two CJK characters occupy four units.

Availability and version history

  • First introduced: Apache OpenOffice 4.0. The official release notes explicitly list MIDB 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, MIDB registry, MIDB implementation.

Syntax and arguments

MIDB(Text; Start; Number)
Argument Required? Meaning
Text Required Source text or a text cell reference.
Start Required First DBCS position to include, starting at 1.
Number Required DBCS units to return.

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: skip a Latin prefix and read a CJK field

Enter A東京B in A2. Its DBCS positions are:

Character DBCS positions
A 1
東 2–3
京 4–5
B 6

Enter =MIDB(A2;2;4) in B2. The expected result is 東京.

Now enter =MIDB(A2;3;3) in B3. The expected result is " 京". Position 3 starts inside 東, so the result begins with a space before the complete 京 character. This is different from MID(A2;3;3), whose positions are character-based.

Additional checks

Formula Expected result What it checks
=MIDB("A東京B";1;1) A First unit.
=MIDB("A東京B";2;4) 東京 Complete two-character field.
=MIDB("A東京B";3;3) " 京" Start splits a two-unit character.
=MIDB("A東京B";2;3) "東 " End splits a two-unit character.
=MIDB("A東京B";6;20) B A long request returns only the remaining text.
=MIDB("A東京B";2;0) Empty text Zero requested length.

For fixed-width DBCS records, document both the starting unit and field width. A prefix that changes from a one-unit Latin character to a two-unit CJK character shifts the start of every later field. A fixed numeric Start is unsafe if the format does not guarantee the prefix width.

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

Start below 1 or a negative Number produces an invalid-argument error. Fractional positions and lengths are floored. Counts beyond the implementation string-length limit fail. A start beyond the text returns empty text. All three arguments are required; MIDB does not provide a default length.

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.

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