CODE Function in ONLYOFFICE Spreadsheet Editor: Syntax and Examples

Text and Data Beginner ONLYOFFICE Spreadsheet Editor

Inspect the code associated with the first character in a text string, useful for finding unwanted leading spaces.

Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in ONLYOFFICE Spreadsheet Editor. How formula examples are checked

CODE function in ONLYOFFICE Spreadsheet Editor

Quick answer

Use =CODE(...) to read the numeric code of the first character of text. The full official syntax is =CODE(text). This guide provides independently reasoned expected results, not results observed in ONLYOFFICE.

What it does and when to use it

CODE identifies the numeric code of the first character, not every character in the cell. ONLYOFFICE describes it in terms of ASCII and explicitly notes case sensitivity. On plain ASCII text, =CODE("A") is expected to return 65 and =CODE("a") 97. These basic examples avoid undocumented code-page and Unicode details. Official CODE help.

Exact syntax and arguments

=CODE(text)
Argument Required? Meaning Example
text Required Text string or single cell reference. The result describes only the first character. "A" or A2

There are 1 required arguments and no documented optional arguments. The names inside the signature are placeholders: do not type text or number literally unless that is a defined cell/range name.

Version, edition, platform and locale applicability

This page is based on the unversioned English ONLYOFFICE Docs Spreadsheet Editor function catalogue and the function-specific official reference, accessed 2026-10-11 UTC. The direct function page confirms the signature described above; it does not state a first-supported build number. Therefore:

  • Docs web/server editor: documented in the current help, but no native execution on an installed Docs build was performed.
  • Desktop Editors: separate desktop changelog consulted; equivalence with any particular Desktop release is not established by the web-editor function article.
  • Mobile/editor integrations: no edition-specific function execution was tested; the current web help is not an exhaustive compatibility matrix.
  • Release context: the Docs changelog records Docs 9.4.0 on May 20, 2026 and the Desktop Editors changelog records Desktop 9.4.0 on May 19, 2026. Neither proves when this exact function was first introduced. Do not convert a changelog’s presence into an invented first-supported version.

All reproducible formulas below follow ONLYOFFICE’s English example convention: begin with =, use () and separate multiple arguments with commas. Literal text in a formula uses double quotes. The function insertion help demonstrates this syntax; Advanced Settings describes a selectable Formula Language and regional settings. Actual localized function spellings and argument separators must be checked on the target installation rather than assuming English settings or a universal semicolon rule.

Practice worksheet and reproducible inputs

Enter the values below as text in column A. For A5, type two ordinary spaces before SKU-3. Preserve the input exactly.

Cell Text value What the first character is
A1 Raw text Header
A2 A Capital A
A3 a Lowercase a
A4 !Stop Exclamation mark
A5 SKU-3 Ordinary space (two leading spaces)
A6 7 cartons Digit seven
A7 Zebra Uppercase Z

Copy the individual formulas into B2:B7. The quotation marks in formulas are typed; the backticks in this guide are not.

Step-by-step instructions

  1. Open a new worksheet and enter the exact values in the data table; check that values specified as text are not automatically converted to dates or numbers.
  2. In the specified output cells, enter the formulas below. Use the Function Arguments dialog (Formula tab) if direct typing is inconvenient.
  3. Compare results to the expected values and explanations; these are reference expectations and independently checked text/ASCII arithmetic, not native test observations.
  4. If an unexpected result appears, first inspect the original cell value, case and hidden spaces; then confirm formula language, separators, arguments, and installed editor version.
  5. Leave source data untouched and record any deviations before applying transformations to real records.

Worked examples: formulas and expected results

Enter in Formula Expected result Explanation
B2 =CODE(A2) 65 Uppercase A is decimal 65 in the common ASCII subset.
B3 =CODE(A3) 97 Lowercase a is decimal 97; CODE is documented as case-sensitive.
B4 =CODE(A4) 33 The first character is !; the word Stop does not change the result.
B5 =CODE(A5) 32 The first of two leading ordinary spaces is decimal 32.
B6 =CODE(A6) 55 The code for the character 7 is 55; it is not numeric 7.
B7 =CODE(A7) 90 Only the initial Z is evaluated.

The examples intentionally avoid unverified high-byte character conversions and long Unicode sequences. Differences in target build, implicit coercion, regional settings, input data, line-break rendering or formula evaluation must be investigated rather than silently changing the expected answer.

Advanced practical applications

Flag suspicious leading spaces during imports

In C5 enter:

=IF(CODE(A5)=32,"Leading ordinary space","Other leading character")

Expected: Leading ordinary space for the two-space input in A5. The criterion detects ASCII space (code 32) only; it is not a complete Unicode whitespace detector. IF syntax is documented separately.

Inspect an explicitly extracted initial character

=CODE(LEFT(A4,1))

Expected: 33. LEFT extracts ! from !Stop, and CODE maps that first character. For this case =CODE(A4) is simpler; the chain is useful only when the extraction step is itself meaningful. The LEFT reference documents the extraction syntax.

Minimal reverse check

=CHAR(CODE(A2))

Expected: A for simple ASCII capital A. Do not generalize to all encodings and multi-character strings: CODE inspects one character, so the remainder is deliberately lost.

Typical mistakes, limitations and edge cases

  1. CODE only inspects the first character. =CODE("A7") and =CODE("A") have the same expected basic-ASCII result: 65.
  2. A leading invisible or ordinary space changes the first-character code; a first-character check is not a validation of every character in the cell.
  3. The official reference documents case sensitivity. Do not treat A and a as equivalent.
  4. The behaviour for an empty string, a blank reference or nontext input is not assigned a specific error code in the source; do not publish an exact error without native execution.
  5. For Unicode or characters above 127, code-page and implementation details are not established by the ONLYOFFICE page. Test the installed build; see UNICODE for a separately documented function.

Troubleshooting when a result differs

  1. Formula appears as text: confirm the leading equals sign, formula cell type, and that pasted quotes use straight " characters, not curly quotes.
  2. Unexpected value: inspect the input with a helper LEN/CODE column or Show Formulas. Invisible characters and formatting can mislead visual inspection.
  3. Unknown function or syntax warning: choose the function from the current Formula tab and confirm its signature in the installed build; then verify English versus localized Formula Language and argument separators.
  4. Wrong result after copying: make sure cell references still point to the intended row; verify capitalization, spaces, and whether a referenced value is stored as a number or text.
  5. Different result from Excel: review the comparison below; do not attribute a difference to a vendor bug without a controlled native reproduction using the same inputs.
  6. Remaining disagreement: save a minimal workbook with raw inputs, the formula, edition/build number, operating system, chosen formula language, expected value and actual value; attach it to manual review.

The official function insertion guide also documents the Formula tab, function argument helper, Show Formulas and forced calculation. No browser action or screenshot was created for this guide.

Differences and transfer notes for other spreadsheet software

Excel: The Excel CODE reference also returns the numeric code of the first character, but states that the code relates to the computer’s character set, with ANSI on Windows versus a Macintosh character set on Mac. ONLYOFFICE’s CODE help uses the term ASCII and does not explain high-code-point platform mappings. Matching function names are not proof of an identical Unicode result.

Cross-software test case: CODE("A") = 65 is a well-defined common-ASCII expectation for comparison. For non-ASCII text, keep each editor’s version, platform and Unicode expectations in a separate validation sheet. The separately documented ONLYOFFICE UNICODE may be more appropriate when Unicode code points are the real goal.

The following official ONLYOFFICE function references were checked for syntax or related workflow, not treated as verified live Spreadsheet-Tutorials.com URLs:

Official reference and verification

Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in ONLYOFFICE Spreadsheet Editor.

  • No genuine ONLYOFFICE Spreadsheet Editor screenshots are included; this guide does not use mock application images.