-
Notifications
You must be signed in to change notification settings - Fork 66
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
fix: apply colors from conditional formatting #6824
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
declaredMethod = rule.getClass().getDeclaredMethod("getDxf", | ||
boolean.class); | ||
declaredMethod.setAccessible(true); | ||
realRule = (CTCfRule) declaredMethod.invoke(rule); | ||
CTDxf dxf = workbook.getStylesSource().getCTStylesheet().getDxfs() | ||
.getDxfArray((int) realRule.getDxfId()); | ||
return dxf; | ||
return (CTDxf) declaredMethod.invoke(rule, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main part of the fix which allows to retrieve the font and background pattern config from the conditional formatting rule.
@@ -288,6 +288,11 @@ public String getBackgroundColorCSS(ConditionalFormattingRule rule) { | |||
|
|||
// CF rules have tint in bgColor but not the XSSFColor. | |||
return styleColor(themeColor, bgColor.getTint()); | |||
} else if (bgColor.isSetIndexed()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows using an indexed color as font / background color.
@@ -14,16 +14,19 @@ public class ColorConverterUtil implements Serializable { | |||
|
|||
public static String toRGBA(byte[] argb) { | |||
int rgba[] = new int[3]; | |||
for (int i = 1; i < argb.length; i++) { | |||
boolean hasAlpha = argb.length == 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently XSSFColor can either hold a byte array with three elements for an RGB color or an array with four elements for an ARGB color. This fixes the logic to also handle RGB byte arrays.
Fixes logic for retrieving text and background color from formatting rules and adds handling of indexed and RGB colors.
Fixes #6819