REPLACE Function in ONLYOFFICE Spreadsheet Editor: Formula and Examples
Use REPLACE and REPLACEB 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
REPLACE changes text at a specified character position. With A6 containing INV-2025-0412, =REPLACE(A6,5,4,"2026") gives the independently calculated result INV-2026-0412. It selects a four-character span beginning at position 5; it does not search for the year 2025.
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 REPLACE reference, vendor illustration and pinned calculation source. Examples were independently calculated; these formulas were not executed in a native application.
Syntax and character positions
REPLACE(old_text, start_num, num_chars, new_text)
All four inputs are required: the original text, the starting position, the number of original characters to remove, and the replacement text. Positions in these ASCII examples start at 1. Replacement text can have a different length from the removed span. The function reference specifies the argument roles; the pinned calculation source removes the selected span and inserts the new string.
The help’s “case-sensitive” note does not make REPLACE a substring search. Changing the case of the text does not move a selected character position. Use SUBSTITUTE when the text to find, rather than its position, determines what should change.
Enter the original text fixture
Create a worksheet named TextCodes with space through column G and row 10. Put Source text in A1 and enter these eight original values:
| Cell | Text input |
|---|---|
| A2 | ORD-4821-ON |
| A3 | PO-1047-Toronto |
| A4 | red-red-red |
| A5 | INV|2026|0412 |
| A6 | INV-2025-0412 |
| A7 | sales@Example.com |
| A8 | ABC-xyz-ABC |
| A9 | PO-0008-WEST |
A5 contains two ordinary vertical bars: INV|2026|0412. Do not type the HTML character codes shown in raw Markdown. Keep the source values as text and leave column A unchanged.
Put Result in B1 and Result length in C1. Enter each formula in its specified cell; these are individual cases rather than a fill-down series:
B2: =REPLACE(A6,5,4,"2026")
B3: =REPLACE(A6,1,3,"ORD")
B4: =REPLACE(A6,1,3,"SO")
B5: =REPLACE(A2,5,4,"9999")
B6: =REPLACE(A7,1,5,"help")
B7: =REPLACE(A9,4,4,"1050")
Enter =LEN(B2) in C2 and fill through C7.
| Row | Expected B | Expected C |
|---|---|---|
| 2 | INV-2026-0412 | 13 |
| 3 | ORD-2025-0412 | 13 |
| 4 | SO-2025-0412 | 12 |
| 5 | ORD-9999-ON | 11 |
| 6 | help@Example.com | 16 |
| 7 | PO-1050-WEST | 12 |
The shorter prefix in B4 shortens the result. Neither a plausible shape nor a preserved length proves that an identifier is registered or unique.
Reproduce the vendor illustration
On a separate worksheet named VendorReplace, enter Online Office in A1 and portal in A2. Put =REPLACE(A1,8,6,A2) in C1. The result is Online portal, as shown in the vendor image. The selected span begins with the O in Office; the space at position 7 stays in place.
For a longer replacement control, put =REPLACE(A1,8,6,"workspace") in C3. The source-based expectation is Online workspace. Enter =LEN(C1) in D1 and =LEN(C3) in D3: the expected lengths are 13 and 16.
Find a delimiter before replacing a field
In TextCodes, reserve E2:E3 for the two original advanced examples:
E2: =REPLACE(A6,FIND("-",A6)+1,4,"2030")
E3: =REPLACE(A2,5,4,"0000")
E2 gives INV-2030-0412; E3 gives ORD-0000-ON. FIND locates the first hyphen, but E2 still assumes a four-character field immediately follows it.
Create a separate VariablePrefix worksheet with A1:E4. Put INV-2025-0412, INVOICE-2025-0412 and PO-0008-WEST in A2:A4. Enter and fill B2:E2 through row 4:
B2: =FIND("-",A2)
C2: =REPLACE(A2,B2+1,4,"2030")
D2: =REPLACE(A2,5,4,"2030")
E2: =EXACT(C2,D2)
| Row | B | C: Delimiter-based | D: Fixed position | E |
|---|---|---|---|---|
| 2 | 4 | INV-2030-0412 | INV-2030-0412 | TRUE |
| 3 | 8 | INVOICE-2030-0412 | INVO20302025-0412 | FALSE |
| 4 | 3 | PO-2030-WEST | PO-02030WEST | FALSE |
The failed fixed-position cases make the layout assumption visible. The delimiter formula is not a complete parser: a missing hyphen triggers FIND’s documented error, and a field of the wrong length still needs separate validation.
Duplicate TextCodes as ChangedYear and replace only A6 with INV-2024-0999. B2 becomes INV-2026-0999, B3 ORD-2024-0999, B4 SO-2024-0999, and E2 INV-2030-0999. Other referenced source cells remain unchanged.
Boundaries, REPLACEB and portability
The pinned source rejects a starting position below 1 or a negative removal count. It also permits a zero removal count in its splice operation. These are source-level observations, not measurements of an installed release; the examples above use positive integer positions and counts.
The shared help distinguishes REPLACE from byte-oriented REPLACEB. In the checked source snapshot, however, REPLACEB inherits REPLACE’s calculation method. That discrepancy does not establish actual DBCS, surrogate-pair or grapheme behavior in a particular build. Keep non-ASCII and byte-oriented migration cases separate from this ASCII worksheet.
Use English names and comma separators as shown, adapting them to the formula editor’s locale settings. Numeric-text conversion, fractional positions, extreme lengths and import behavior remain outside these examples. Preserve raw inputs and inspect changed output before applying a transformation to real records.
Related guides
- SUBSTITUTE replaces literal matches.
- FIND locates a case-sensitive substring.
- LEN checks output length.
- EXACT compares the two complete output strings.
REPLACEB: documented byte-oriented variant
REPLACEB(old_text, start_num, num_bytes, new_text)
All four arguments are required: original text, starting position, removal count and replacement text. The documented num_bytes counts the removed span in bytes. The operation selects a position; it does not search for the old text.
Documentation and implementation are different evidence
The official REPLACE/REPLACEB reference describes REPLACEB for byte-oriented or double-byte-character-set language use. However, the pinned REPLACEB implementation directly inherits REPLACE, 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 REPLACEB
On a separate ReplacebControls 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 |
|---|---|---|
=REPLACEB("ORD-4821",5,4,"9000") |
ORD-9000 | Replace the four digits while retaining the prefix. |
=REPLACEB("ABC",2,1,"x") |
AxC | Replace B at position 2 with x. |
=REPLACEB("ABC",2,0,"-") |
A-BC | A zero removal count inserts without deleting. |
=REPLACEB("ABC",2,1,"") |
AC | Empty replacement deletes the selected position. |
=REPLACEB("ABC",0,1,"x") |
#VALUE! | A start below 1 is rejected by the inherited calculation. |
The zero-count control inserts a hyphen without removing B. A replacement may be longer or shorter than its removed span. Preserve the original column and inspect both the changed text and its length before using the transformation on real identifiers.
Migrating a workbook that uses REPLACEB
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 REPLACEB with REPLACE 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.