We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Conditional formatting styles

I am using code to setup some conditional formatting rules for a cell. If I setup the formula and the style in code, everything works beautifully. However, if I use a cell to copy the styles from when setting up the conditional formatting, none of the styles from the cell are copied to the format of the conditional formatting rule.
Your help is much appreciated. I’m using version of Cells.

Here is my code:

// get the styles from worksheet 1
Style style = wb.Worksheets[1].Cells[0,0].GetDisplayStyle();

// create the conditional formatting on worksheet 0
int conditionalFormattingIndex = wb.Worksheets[0].ConditionalFormattings.Add();
FormatConditions formatConditions = wb.Worksheets[0].ConditionalFormattings[conditionalFormattingIndex];
// setup the cell A1 on worksheet 0
CellArea cellArea = new CellArea();
cellArea.StartColumn = 0;
cellArea.StartRow = 0;
cellArea.EndColumn = 0;
cellArea.EndRow = 0;
string actualFormula = “=$A$1>0”;
int formatConditionIndex = formatConditions.AddCondition(FormatConditionType.Expression, OperatorType.None,actualFormula , null);
FormatCondition formatCondition = formatConditions[formatConditionIndex];
// copy the style


Thanks for our inquiry.

Well, we do not support FormatCondition.Style.Copy() method in this scenario. Kindly set each property of the Style individually by yourself while applying formattings to the format condition.


formatCondition.Style.Borders[BorderType.TopBorder].LineStyle = style.Borders[BorderType.TopBorder].LineStyle;

formatCondition.Style.Font.Color = style.Font.Color;

formatCondition.Style.Font.IsBold = true;

If you still find any issue, kindly post your template file with sample code here, we will check it soon.

Thank you.