No Excel, usando o Interop dll, tenho o seguinte código.
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;
Como conseguir a formatação condicional no Excel usando o Office Writer?
Tags microsoft-excel