В Excel, используя Interop DLL у меня есть следующий код.
objWorkSheet.Range[objExcel.Cells[intHeaderRowCnt + 2, 6], objExcel.Cells[intCellRowCnt, 6]].Formula = "=RC[-3]-RC[-1]";
objWorkSheet.Range[objExcel.Cells[intHeaderRowCnt + 2, 6], objExcel.Cells[intCellRowCnt - 1, 6]].FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlGreater, 0, 0);
objWorkSheet.Range[objExcel.Cells[intHeaderRowCnt + 2, 6], objExcel.Cells[intCellRowCnt - 1, 6]].FormatConditions[1].Interior.ColorIndex = 3;
objWorkSheet.Range[objExcel.Cells[intHeaderRowCnt + 2, 6], objExcel.Cells[intCellRowCnt - 1, 6]].FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlLess, 0, 0);
objWorkSheet.Range[objExcel.Cells[intHeaderRowCnt + 2, 6], objExcel.Cells[intCellRowCnt - 1, 6]].FormatConditions[2].Interior.ColorIndex = 4;
Как добиться условного форматирования в Excel с помощью Office Writer?