Unplanned
Last Updated: 23 May 2023 14:05 by ADMIN
ADMIN
Anna
Created on: 23 May 2023 14:05
Category: SpreadProcessing
Type: Bug Report
0
SpreadProcessing: Adding conditional formatting rule with empty formatting results in a corrupted document

If a rule is added with no formatting (for example, in the case when we want to add a rule which preserves the default formatting in some cases) the exported document is corrupted.

DifferentialFormatting formatting2 = new DifferentialFormatting();

ContainsBlanksRule rule2 = new ContainsBlanksRule(formatting2);
rule2.Formatting = formatting2;

ConditionalFormatting conditionalFormatting2 = new ConditionalFormatting(rule2);
worksheet.Cells[1, 2, 12, 2].AddConditionalFormatting(conditionalFormatting2);

A possible workaround is to add formatting to the rule, which copies the default:

DifferentialFormatting formatting2 = new DifferentialFormatting();
formatting2.Fill = new PatternFill(PatternType.Solid, Colors.Transparent, Colors.Transparent);
CellBorder border = new CellBorder(CellBorderStyle.Thin, new ThemableColor(Color.FromRgb(212, 212, 212)));
formatting2.LeftBorder = border;
formatting2.TopBorder = border;
formatting2.RightBorder = border;
formatting2.BottomBorder = border;
0 comments