Bug 166683 - Conditional formatting, Styles: A way to define only partial set of cell settings is required
Summary: Conditional formatting, Styles: A way to define only partial set of cell sett...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Conditional-Formatting Calc-Styles
  Show dependency treegraph
 
Reported: 2025-05-22 07:15 UTC by Mike Kaganski
Modified: 2025-05-23 21:30 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Sample file (11.44 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-22 22:38 UTC, m_a_riosv
Details
Three columns (11.32 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-23 04:29 UTC, Mike Kaganski
Details
Sample file with CF (38.38 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-23 11:29 UTC, m_a_riosv
Details
An example after playing with GreenRow's number format (34.05 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-05-23 14:20 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2025-05-22 07:15:49 UTC
In Calc, conditional formatting applies cell styles, which each define a *complete* set of cell properties. That means, that you can't create a conditional formatting that only changes a certain aspect of formatting in an existing cell, and keeps the rest, like "make font color red, but keep number format as set to the cell by its own cell style / direct formatting". This is consistent and has its logic; but it (1) created confusion, and (2) what's more problematic, is inflexible and provokes style proliferation, and conditional format proliferation, affecting manageability. There already had been a change trying to meet users' expectations un bug 93300 - calusing its own set of problems, and reverted in bug 117715. The problem is real, with many bug reports (See Also has some of them), and Ask questions.

Consider a sheet with some columns, where each column may have different formatting: some columns can contain text, some dates, some numbers in different formats (percent, currency, etc.). If a user wants to apply a conditional formatting to the table, such as to highlight the whole row using red background, when some column value meets a condition - they can't just use a single style for all the columns - they will have to create separate "red background for dates", "red background for text", "red background for currency"... styles, each of them would have the red background, but own number format. Then, these different cell formats, which would need to be applied to respective columns when that condition is met, will require the respective number of *separate* condition formattings defined - each for own cell range.

This is already a burden to create all them; but consider a task when you decide to change the condition, or decide to change some formatting of a column, or a color of highlighting. All of them would now require to make changes to multiple places instead of one - basically ruining the styled approach benefits ("make the change in a single place, have it everywhere"). Changing the CF condition requires to change all the fragmented CFs. Changing color of highlighting requires to change it in all styles (one could argue, that you can create a base style for all such styles, and do the change there; but here is a problem: which style should be the base? Basing the CF style on the "normal" cell style of the same type can be another option; and a base CF style just shifts the problem elsewhere - see the following). Changing a column formatting, when your CF styles aren't based on the respective "normal" style, will require to change both normal and CF style (and there's no way to experiment using direct formatting in this scheme)...

So we need a way to define a *partial set* of setting to apply using CF rules. Possibly that needs to be a new type of style?
Comment 1 m_a_riosv 2025-05-22 22:38:50 UTC
Created attachment 200922 [details]
Sample file

I think it works like this, I don't know if it works in all cases.

Please check the attached file.

A1:A4 has the Result style applied.

When the cell is equal to 333 RedText style is applied by the CF

RedText also inherits from Default.

Version: 25.8.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 6190fe56f72008e0b6d0e502bf94099e72b9d202
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded
Comment 2 m_a_riosv 2025-05-22 22:41:51 UTC
RedText has 10 font size, and Result has 15. The only modification on RedText over Default is the font color.
CF applies the red font but with the font size of Result style.
Comment 3 Mike Kaganski 2025-05-23 04:16:06 UTC
(In reply to m_a_riosv from comment #1)

Please re-read comment 0, and pay specific attention to

> Consider a sheet with some columns, where each column may have different
> formatting

The different columns part, and different formatting for each, are important to understand the issue.
Comment 4 Mike Kaganski 2025-05-23 04:29:00 UTC
Created attachment 200923 [details]
Three columns

Please take this table. It has three columns, first name, second date, third number. Please try to make a conditional formatting, so that for anyone with height > 115, show the whole row green. The goal is to have a single CF rule for the whole range ("column C is > 115 -> apply style X").
Comment 5 m_a_riosv 2025-05-23 11:29:34 UTC
Created attachment 200925 [details]
Sample file with CF

At first, I was thinking if the issue could be with preference of direct format.
But after create the CF, I don't know if there is some difference, but works for me.
Version: 25.2.4.1 (X86_64) / LibreOffice Community
Build ID: 09303ce8b49f86f106fccd32b1324662053027cc
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: en-US (es_ES); UI: en-US
Calc: CL threaded
Comment 6 Mike Kaganski 2025-05-23 14:20:43 UTC
Created attachment 200933 [details]
An example after playing with GreenRow's number format

Hmm, that's unexpected. I seem to be totally confused; the attachment shows what I always saw - but I never realized what you shown. Thanks!

I need to think about it, maybe debug. Likely we just need means to reset style formatting, after all.
Comment 7 m_a_riosv 2025-05-23 21:30:08 UTC
I think this was already reported in tdf#108373

In your sample, using a style for the cells with dates instead of direct format, lets CF works right.

It seems like direct formatting is sometimes reset by CF style.
Before my jubilee, a few years ago, I dealt with that issue, solving it with a row above the column names to define the data type in the column and select the style in the CF.