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

Free Support Forum - aspose.com

Conditional formatting styles

Hi,
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 4.5.1.13 version of Cells.
Thanks.
lama


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;
formatConditions.AddArea(cellArea);
string actualFormula = “=$A$1>0”;
int formatConditionIndex = formatConditions.AddCondition(FormatConditionType.Expression, OperatorType.None,actualFormula , null);
FormatCondition formatCondition = formatConditions[formatConditionIndex];
// copy the style
formatCondition.Style.Copy(style);

Hi,

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.

e.g..,

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.