Hello,
Thanks for your hotfix. It resolved some issues (StopIfTrue...) but it still one not easy to reproduce
In attachement, you will find 2 files : "Sample.xlsm" and "Sample - out.xlsm"
"Sample.xlsm" is the file source file to which I want to add conditional formats.
"Sample - out.xlsm" is the file update with Spire 7.12.125 and source code following.
- Code: Select all
var workbook = new Workbook();
workbook.LoadFromFile(Chemin + "Sample.xlsm");
#region CA N-N-1
var worksheet = workbook.Worksheets[0];
var range = worksheet.Range["C7:C18"];
var cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Less;
cond.FirstFormula = "0";
cond.FontColor = Color.Red;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "0";
cond.FontColor = Color.Green;
range = worksheet.Range["C24:C35"];
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Less;
cond.FirstFormula = "0";
cond.FontColor = Color.Red;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "0";
cond.FontColor = Color.Green;
#endregion CA N-N-1
#region CA OBJECTIF
worksheet = workbook.Worksheets[1];
range = worksheet.Range["C7:C18"];
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "1";
cond.FontColor = Color.Green;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "0.85";
cond.FontColor = Color.Orange;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Less;
cond.FirstFormula = "0.85";
cond.FontColor = Color.Red;
range = worksheet.Range["C24:C35"];
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "1";
cond.FontColor = Color.Green;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Greater;
cond.FirstFormula = "0.85";
cond.FontColor = Color.Orange;
cond = range.ConditionalFormats.AddCondition(ConditionalFormatType.CellValue, true);
cond.Operator = ComparisonOperatorType.Less;
cond.FirstFormula = "0.85";
cond.FontColor = Color.Red;
#endregion CA OBJECTIF
workbook.SaveToFile(Chemin + "Sample - Out.xlsm", ExcelVersion.Version2016);
Sheet 1 "ca-n-n-1" is correct !
My issues is in sheet 2 "ca-objectifs".
Number of conditional format is correct but not order, range source and colors.
You will find more information in "Sample - Out.
I think the problems are that the ranges are the same between the 2 sheets...
Said me if you do'nt reproduce the issues.
Thanks