22 7

Two Calc functions for counting cells or cell content by cell style. Compatible with both Apache OpenOffice and LibreOffice.

Project Description

COUNTSTYLE is an extension dedicated to the Calc module.

It is aimed to perform operations based on the cell formatting, such as typically (but not only) the background colour.



Download the most recent countstyle-x.x.x.oxt file and install it from Tools->Extension Manager.

Restart the program.

Countstyle adds two new functions to Calc, accessible from the function wizard: COUNTSTYLE and CELLSTYLE.

Formulas using these functions are automatically updated when a new style is applied.


COUNTSTYLE(range, style [, function])

<range>: the referred cell range
<style>: the style to count (case sensitive)
<function>: an integer giving the operation to compute
    0 or missing argument: number of cells
    1: sum of values
    2: number of non empty cells
    3: average of values
    4: maximal value
    5: minimal value
    6: number of numeric values


<cell>: the cell from which you want to get the style


  • fr

COMPTE.STYLE(plage, style [, fonction])


  • it

CONTA.STILE(area, stile [, funzione])



By design, COUNTSTYLE only counts cells formatted with the style given as argument. Direct formatting is ignored and colour names are not allowed.
COUNTSTYLE doesn't work with style applied by mean of conditional formatting: not only would this be awkward and unwiedly (there is no easy API method to retrieve such colouring), but also useless, as you just need to count cells on the same condition used for formatting.

Why counting styles rather than colours?

It's far easier for the user to define a style rather that trying to retrieve a colour reference.
And what should this reference be: the colour name?, the decimal value?, the rgb or the hexadecimal representation?

By the way, what colour should COUNTSTYLE count: the background colour?, the characters colour?, the borders one?...

Colour are not the same for everyone, and besides, colour names and values differ between OpenOffice and LibreOffice. For example, OpenOffice "red" is rgb 255,51,51, while one would expect 255,0,0!

With styles you can count coloured cells, but you can also count on any property you want: background or character colour, character weight, cell borders, font, any mix of those and so on...


Calc Extension

Homepage of the Project

Current Release

CountStyle - 1.0

Released Aug 11, 2018 — tested with:

LibreOffice 3.3, LibreOffice 3.4, LibreOffice 3.5, LibreOffice 3.6, LibreOffice 4.0, LibreOffice 4.1, LibreOffice 4.2, LibreOffice 4.3, LibreOffice 4.4, LibreOffice 5.0, LibreOffice 5.1, LibreOffice 5.2, LibreOffice 5.3, LibreOffice 5.4, LibreOffice 6.0, LibreOffice 6.1, LibreOffice 6.2,

Initial release
More about this release…

All platforms

All Releases









Aug 11, 2018
  • All platforms
  • LibreOffice 3.3
  • LibreOffice 3.4
  • LibreOffice 3.5
  • LibreOffice 3.6
  • LibreOffice 4.0
  • LibreOffice 4.1
  • LibreOffice 4.2
  • LibreOffice 4.3
  • LibreOffice 4.4
  • LibreOffice 5.0
  • LibreOffice 5.1
  • LibreOffice 5.2
  • LibreOffice 5.3
  • LibreOffice 5.4
  • LibreOffice 6.0
  • LibreOffice 6.1
  • LibreOffice 6.2
Initial release
  • AL-v2 (Apache License Version 2.0)

Legal Disclaimer and Limitations for Downloads

The Document Foundation has not reviewed, and cannot review, all of the material, including computer software, available on or by means of The Document Foundation's
websites, and cannot therefore be responsible for that material's content, use or effects. By operating its websites, The Document Foundation does not represent or imply that it endorses the material there available, or that it believes such material to be accurate, useful or nonharmful. You are responsible for taking precautions as necessary to protect yourself and your computer systems from viruses, worms, Trojan horses and other harmful or destructive content. The Document Foundation's websites may contain content that is offensive, indecent or otherwise objectionable, as well as content containing technical inaccuracies, typographical mistakes and other errors. The Document Foundation's websites may also contain material that violates the privacy or publicity rights, or infringes the proprietary rights, of third parties, or the downloading, copying or use of which is subject to additional terms and conditions, stated or unstated. The Document Foundation disclaims any responsibility for any harm resulting from the use by The Document Foundation's visitors of The Document Foundation's websites, or from any downloading by those visitors of content available on or by means of The Document Foundation's websites.


Content contained on The Document Foundation's websites, including these Legal Disclaimers and Limitations, may be changed at the sole discretion of The Document Foundation and without notice. You are bound by any such updates or changes, and so should periodically review these Legal Disclaimers and Limitations.

If you believe any file is present on the site contrary to any TDF rule or applicable law, please supply full details to for impartial consideration.