Contact

COLUMNS Function in ONLYOFFICE Spreadsheet Editor: Syntax and Worked Examples

Lookup and Reference Beginner ONLYOFFICE Spreadsheet Editor

Count columns in a cell range, check report widths and distinguish column count from worksheet column numbers.

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

Quick answer

Use =COLUMNS(B2:D7) to return 3 because B, C and D form a three-column-wide rectangular range. COLUMNS measures width, not the number of nonempty headings or the letter/index of the last column. This guide uses the documented English ONLYOFFICE COLUMNS reference, checked October 13, 2026. All worked example results are independent expected results, not native execution measurements.

What it does and what it does not do

Use COLUMNS to confirm a report contains an expected number of fields, generate an incremental horizontal position counter, and size rectangular data blocks. Its result follows the referenced grid geometry. It does not inspect whether a particular header or data cell is filled. The ONLYOFFICE COLUMNS function explicitly describes returning the number of columns in a cell reference.

Exact official syntax and argument definitions

=COLUMNS(array)
Argument Required Type and purpose Default
array Yes A reference to a range of cells whose horizontal width (number of columns) is counted. This is the officially documented argument type. No default documented

The official syntax is COLUMNS(array) with a single required argument and no optional parameters. Although the parameter is named array, the individual ONLYOFFICE help article describes a cell-range reference. It does not document an option to ignore blanks, hidden positions, filtered records or empty headers. Claims about non-contiguous ranges and array constants are deliberately withheld pending native validation (official function page).

Verified product scope, formula language and validation

The ONLYOFFICE Spreadsheet Editor function catalogue lists this name under Lookup and Reference Functions; its individual official article supplies the syntax below. Documentation access date: October 13, 2026. The English help pages are unversioned and do not establish a minimum ONLYOFFICE Desktop Editors build, a minimum ONLYOFFICE Docs server release, or identical results on every platform. The Formula tab help illustrates both online and desktop Spreadsheet Editors, but native formula execution was not performed on either. Platform support is therefore official-documentation-listed; runtime versions and platform parity remain unverified.

Examples use English function names and standard A1 references. The English Insert Functions instructions show a comma for separating multiple arguments. These particular functions take only one argument, so a separator is not required unless they are nested in another function such as IF. ONLYOFFICE’s Advanced Settings documents selectable formula language and regional settings; inspect your own interface if a localized formula cannot be pasted verbatim. A decimal/thousands display separator is not automatically proof of the formula argument separator.

Validation: source-documentation review plus independent counting of worksheet coordinates and expected arithmetic. All labelled results below are expected, never measured outputs. Native web run: not performed. Native desktop run: not performed. Imported XLSX behavior, named ranges, non-contiguous unions and edge-case errors were not tested.

Build a reproducible worksheet

Start a blank sheet and type the following values exactly into A1:D7; do not paste the backticks. Leave A5 genuinely blank (do not enter a space, an apostrophe or an empty-string formula). The sample table describes where each value goes and is not itself a claim of a tested spreadsheet file.

Cell Value to enter Purpose
A1 Order Identifier header
B1 Region Region header
C1 Units Numeric data header
D1 Status Status header
A2:D2 T101, West, 4, Ready First record
A3:D3 T102, East, 2, Hold Second record
A4:D4 T103, West, 6, Ready Third record
A5:D5 Leave A5 completely empty; enter West, 3, Hold in B5:D5 Deliberately blank identifier; this row is still inside the range
A6:D6 T105, North, 8, Ready Fifth record
A7:D7 T106, East, 1, Ready Sixth record

Type the following formulas into unused cells outside A1:D7 to avoid replacing the sample data.

Copy-ready formulas and independently calculated expected results

Formula Expected result Why
=COLUMNS(B2:D7) 3 Columns B, C and D are included.
=COLUMNS(A1:D1) 4 Four header positions A through D.
=COLUMNS(A2:A7) 1 One vertical column is one column wide.
=COLUMNS(D5:D5) 1 A one-cell range is one column wide.
=COLUMNS(A2:F2) 6 Six inclusive columns A through F.
=COLUMNS(C2:D7) 2 Only C and D are included.
=COLUMNS($B$2:B2) 1 Initial formula before copying right.
=COLUMNS(B2:D7)-COLUMNS(C2:D7) 1 Three columns minus two.
=COLUMNS(B2:D7)=3 TRUE The width is exactly three.
=IF(COLUMNS(A1:D1)=4,"Four fields","Check source columns") Four fields The four-column check evaluates TRUE.
=ROWS(B2:D7)*COLUMNS(B2:D7) 18 Six rows times three columns.
=COLUMN(D2) 4 COLUMN reports D’s worksheet position, unlike COLUMNS.

The “expected” column follows directly from the rectangular cell references, their inclusive endpoints, and the checked function definition. These outcomes were not observed in a running ONLYOFFICE editor. In the examples containing IF or another function, that companion function was separately checked against its official reference.

Advanced applications, with verification boundaries

1. Detect a changed file schema before importing

=IF(COLUMNS(A1:D1)=4,"Four fields","Check source columns") returns expected Four fields. This checks the declared rectangle’s width, not whether headers are correctly named. The official IF reference supports the two-way choice. For a strict schema check, compare actual header text separately.

2. Number a horizontal report without typing 1, 2, 3

Place =COLUMNS($B$2:B2) in F2, then copy right into G2:H2. Expected results are 1, 2, 3 because the left endpoint remains B2 while the relative right endpoint advances B2 → C2 → D2. These are positions in the widening reference, not worksheet column identifiers. If an editor changes the filled references unexpectedly, inspect the formula text before using in a client report.

3. Calculate cells available in a rectangular block

=ROWS(B2:D7)*COLUMNS(B2:D7) is expected 18 cell positions. The count includes spaces occupied by empty cells: an area of six rows and three columns has 18 slots regardless of occupancy. The ROWS function defines the companion height measurement.

4. Distinguish field count from field location

=COLUMNS(B2:D7) is 3 because the rectangle is three columns wide. =COLUMN(D2) is 4 because D is the fourth worksheet column. Use the COLUMN function if you need a position/address rather than a width. A header check on A1:D1 can have width four even if one header cell is empty.

Errors, limitations and troubleshooting

  1. You expected the rightmost column number. COLUMNS gives width, not the ending column index: B:D is three columns wide, though D is worksheet column four. Use COLUMN for an index.
  2. A blank header is present. The rectangle A1:D1 is four columns wide even if C1 is empty. COLUMNS is not a count of nonempty header labels.
  3. A column was left out. COLUMNS(B2:C7) is 2, whereas COLUMNS(B2:D7) is 3. Inspect the final column letter.
  4. Quoted address instead of a reference. The official argument is a range reference. =COLUMNS("B2:D7") is not a documented way to supply that reference. Exact error text remains untested.
  5. Missing required input. The documented signature has one required array. Do not assume the empty call works; correct the missing argument. No particular native error code has been claimed here.
  6. Range shifted during copy. Mixed $ references can freeze the wrong endpoint. Inspect F2, G2, and H2 in the horizontal count example to ensure they are widening as intended.
  7. Noncontiguous/3-D references. The vendor article does not document a union of disconnected areas or multi-sheet behavior; neither is claimed compatible without a native test.
  8. Array literal compatibility. Excel also documents COLUMNS on array constants. The ONLYOFFICE page describes cell-range references; cross-engine behavior for literal arrays remains unverified.

Excel cross-compatibility and other spreadsheet software

The independently checked Microsoft Excel COLUMNS article uses the same basic signature COLUMNS(array) and agrees on the dimension-counting purpose, so the simple A1-style range examples are meaningful to an Excel user as well. That is not a blanket compatibility guarantee: Excel’s documentation additionally discusses array constants and different releases. The ONLYOFFICE article supports the documented range-based use here; array-constant and import-parity tests in this document were not executed. No compatibility assertion is made for Google Sheets, LibreOffice Calc, mobile variants or every localized build.

Checked sources, access dates and validation log

  • ONLYOFFICE COLUMNS function — accessed 2026-10-13; source for purpose, signature, required range input, and the fact that the reference is a geometric dimension rather than an occupancy test.
  • ONLYOFFICE Insert Functions — accessed 2026-10-13; presence in the Lookup and Reference category, editor insertion workflow and English formula examples.
  • ONLYOFFICE Formula tab — accessed 2026-10-13; documents desktop and web editor interfaces; not a minimum-version proof.
  • ONLYOFFICE Advanced Settings — accessed 2026-10-13; provides formula-language and region settings context.
  • Microsoft COLUMNS function — accessed 2026-10-13; comparison only, not proof of ONLYOFFICE behavior outside the vendor specification.
  • ONLYOFFICE ROWS, COLUMNS, ROW, COLUMN, COUNTA, and IF — accessed 2026-10-13; supporting related concepts and cross-check formulas. Links were individually checked against the official help centre.

Verification: All coordinate calculations are independent expectations. Native Desktop/web scalar and array execution, localized parsing, historical versions and workbook interchange were not tested.