After some research and games, I find that I have found the best answer. The following code will alternate the colors of the lines for the worksheet.
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Interop.Excel.Application(); Workbook workbook = excel.Workbook.Add(); Worksheet worksheet = workbook.Worksheets.Item[1]; FormatCondition format = worksheet.Rows.FormatConditions.Add(XlFormatConditionType.xlExpression, XLFormatConditionOperator.xlEqual, "=MOD(ROW(),2) = 0"); format.Interior.Color = XlRgbColor.rgbBlue;
source share