PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

Conditional styles comming separates, even though two of them are one conditional style when you open the sheet

Open bokrma opened this issue 1 year ago • 2 comments

when I tried to import a sheet using the function: $this->worksheet->getConditionalStylesCollection(); the data inside of it was splitter by ranges but in reality there are two ranges belong to one set of conditional styling can you please provide a general function that fetches the conditional stylings as its defined? Conditional styles test.xlsx this is a test file to check with

bokrma avatar May 22 '24 10:05 bokrma

Thank you for providing a sample file. In it, the style is stored as:

<conditionalFormatting sqref="B1:B10 C1:C10">

I am not sure why it is not stored as:

<conditionalFormatting sqref="B1:C10">

If the latter form were used, you would only see a single style, as you wish. Since the former form is used (and I don't know why that is the case), we do our best to interpret the split range, and "our best", in this case, is to treat it as 2 separate ranges. As far as I can tell, this still results in a correct spreadsheet, with the conditional working correctly for both ranges.

I confess that I am not sure why we need to split the range, but I don't know if not splitting it will lead to regression problems. Before I begin investigating, can you tell me why it matters to you?

oleibman avatar May 22 '24 16:05 oleibman

the idea of having it as it's defined, is that if the user import it to our system, we need to know if its defined as signluar or 2 ranges, or multiple (since it could be many 4-5 ranges, etc) and our code generates the database related to it and shows it in a frontend like Excel sheet Screenshot 2024-05-23 at 11 20 36

Screenshot 2024-05-23 at 11 21 37

bokrma avatar May 23 '24 09:05 bokrma