-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with condtional formatting with PHPspreadsheet #2678
Comments
I've been doing some work with CF over the last few days; and I can see the logic in the ReferenceHelper to move the cell range for the style; but I can't see any logic to adjust cell references in the conditions. I'll take a look at it as part of that work. |
Taking a deeper look at the existing code while I was having my lunch break: the existing code only seems to be updating the cell styling if the insert falls within the CF range; but doesn't update the range itself, nor the conditions :-( |
Hi Mark, THISPAGEHASACODINGPROBLEM |
Is this related to Condiional Formatting? Or is it just a formula error? |
In my template I have formulas earlier(same formula) also, But only change updated the phpspreadhseet code with latest changes(my phpspreadsheet code one year old). |
If it's not related to this Conditional Formatting Issue, then please raise it as a separate issue, otherwise tracking the investigation and the work involved in resolving it becomes a lot harder. To help debug a formula issue, the following code may be useful:
|
Although looking more closely, it seems that INDIRECT rejects row/column ranges with a |
Hi , I am using the below code to update the conditional style, but the all rows having the same condition ( I mean the condition is overriding with the last condition) $aStyles = $sheet->getConditionalStylesCollection();
$ros = 2;
foreach ($aStyles as $cellAddress => $cfRules) {
foreach ($cfRules as &$cfRule) {
$conditions = $cfRule->getConditions();
foreach ($conditions as &$condition) {
if (is_string($condition)) {
$cfRule->setConditions('$C$'.$ros);
}
}
}
$ros ++;
} What needs to be done to get as above, it seems the condition:PhpOffice\PhpSpreadsheet\Style\Conditional:private is global condition? |
Without delving too closely into this, I'd suggest that your use of "by reference" might cause some problems What are you actually trying to achieve here? Because And no, conditions are not "global" P.S. When you have a completely new question to ask, please raise a new issue.... don't simply piggy-back on this issue for every single question that you have.... it makes any kind of issue tracking that we are trying to do nearly impossible!!! |
My condition formatting as attached. What I am trying to do is reading the Conditional styles with the getConditionalStylesCollection(say condition is in row now 6 and copying the same condition to the other newly inserted cell (at row no 7)) and I am changing that condition with below statement. When I changed, the condition in the screen shot(un the row no 6) also changing to Cell value > $AL$7,Cell value < $AL$7, Cell value = $AL$7. This is not a new question , this is related to the same question which I posted earlier. |
There is actually code in the master branch of PhpSpreadsheet that will do this work when you insert rows: https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/ReferenceHelper.php#L209 by this PR on 1th March (if you want to duplicate that).... or run the script against the master branch if you don't want to rewrite changes that have already been implemented. Or use the CF Wizards to change the conditional range |
This is:
What is the expected behavior?
I have a template excel, where I have some headers, formulas and conditional styles. I am writing data to the cells and styles are applying.
I have condition on row 8 in column A as greater than $M$8 then apply some format.
So my condition should change for 9th row column A like $M$9 , for 10 th row $M10 and so on.
If I insert new row before 8th row 8th row will become 9th row and the condition will get change to $M$9.
What is the current behavior?
But my condition is still same (like $M$8 for 9,10,11.... rows) through phpspreadsheet.
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
Which versions of PhpSpreadsheet and PHP are affected?
The text was updated successfully, but these errors were encountered: