CELL Function (LibreOffice Calc)

Information Advanced LibreOffice Calc Introduced in LibreOffice 3.0
information metadata diagnostics formatting references

The CELL function in LibreOffice Calc returns detailed metadata about a cell, such as its address, filename, format, column width, protection status, and more. It is essential for diagnostics, dynamic formatting, and advanced spreadsheet automation.

Compatibility

â–¾

What the CELL Function Does â–¾

  • Returns metadata about a cell
  • Supports multiple info types (address, filename, format, width, protection, etc.)
  • Useful for diagnostics and dynamic logic
  • Works with direct references and reference‑returning formulas

It is designed to be flexible, metadata‑rich, and essential for advanced workflows.

Syntax â–¾

CELL(info_type; reference)

Arguments

  • info_type:
    A text keyword specifying the metadata to return.

  • reference:
    A cell reference to inspect.

Supported CELL Info Types in LibreOffice Calc â–¾

Info Type Description Example Output
“address” Absolute cell address “$A$1”
“col” Column number 1
“row” Row number 1
“filename” Full path + sheet name “/path/file.ods#Sheet1”
“color” 1 if cell is formatted in color for negative values 0
“contents” Cell contents Value of the cell
“type” Type code: b (blank), l (label), v (value) “v”
“format” Number format code “F0”, “D2”, etc.
“prefix” Label prefix (’ for text) “'”
“protect” 1 if locked, 0 if not 1
“width” Column width in units Platform‑dependent

Unsupported types return Err:502.

Basic Examples â–¾

Get the address of A1

=CELL("address"; A1)

Returns "$A$1".

Get the filename of the current document

=CELL("filename"; A1)

Get the column number

=CELL("col"; C5)

Returns 3.

Get the row number

=CELL("row"; C5)

Returns 5.

Get the contents of a cell

=CELL("contents"; A1)

Get the number format code

=CELL("format"; A1)

Advanced Examples â–¾

Detect if a cell is locked

=CELL("protect"; A1)

Useful for template protection logic.

Detect if a cell contains text vs number

=CELL("type"; A1)

Returns:

  • "b" → blank
  • "l" → label (text)
  • "v" → value (number)

Get the sheet name from filename

=RIGHT(CELL("filename"; A1); LEN(CELL("filename"; A1)) - FIND("#"; CELL("filename"; A1)))

Build dynamic references using CELL + INDIRECT

=INDIRECT(CELL("address"; A1))

Detect negative‑number formatting

=CELL("color"; A1)

Returns 1 if negative numbers are formatted in color.

Get column width for layout logic

=CELL("width"; A1)

Use CELL to track active cell (Excel‑style behavior)

LibreOffice does not update CELL(“address”) based on active selection unless recalculated manually.

Use CELL to detect formatting changes

=CELL("format"; A1)

Useful for conditional formatting diagnostics.

Edge Cases and Behavior Details â–¾

CELL(“filename”) requires the file to be saved

Unsaved documents return an empty string.

CELL(“address”) always returns absolute references

"$A$1"  
"$C$5"

CELL(“type”) returns:

  • "b" for blank
  • "l" for text
  • "v" for numbers

CELL(“contents”) returns the raw value

  • Dates return serial numbers
  • Times return fractional days
  • Formulas return their result

CELL(“format”) returns internal format codes

These are not user‑friendly; they are engine‑level identifiers.

CELL does not auto‑update on selection change

Recalculate manually to refresh.

Unsupported info types return Err:502

LibreOffice supports fewer types than Excel.

Common Errors and Fixes â–¾

Err:502 — Invalid argument

Occurs when:

  • info_type is unsupported
  • info_type is misspelled
  • info_type is not text

CELL returns outdated information

Cause:

  • CELL does not auto‑refresh
  • Requires manual recalculation

CELL(“filename”) returns empty string

Cause:

  • File has not been saved yet

CELL(“contents”) returns unexpected values

Cause:

  • Dates/times are numeric
  • Formulas return results, not formulas

Best Practices â–¾

  • Use CELL for metadata‑driven automation
  • Use CELL(“filename”) for document‑aware logic
  • Use CELL(“type”) to distinguish text vs numbers
  • Use CELL(“protect”) for template protection workflows
  • Recalculate manually when using CELL in dashboards
CELL is your metadata powerhouse — perfect for diagnostics, dynamic formatting, and environment‑aware spreadsheet logic.

Related Patterns and Alternatives â–¾

  • Use INFO for system‑level metadata
  • Use TYPE for data‑type inspection
  • Use ADDRESS and INDIRECT for dynamic references
  • Use ROW and COLUMN for positional logic
  • Use ISREF and ISERROR for validation

By mastering CELL and its companion functions, you can build metadata‑aware, dynamic, and highly automated spreadsheets in LibreOffice Calc.

Copyright 2026. All rights reserved.