How to do alternate line rotation using Office.Interop.Excel?

I am using Office Interop through C # 4.0 to write an Excel file. I would like to obscure alternating lines. I know how to do this with a GUI in Excel. I could also scroll through each line to provide shading, but this option is unacceptably slow with large datasets. Is there a way using Office.Interop.Excel to set conditional formatting options found in Excel GUI?

EDIT: Added More Information

Using C # with .NET 4.0 and Office Interop 2007

+4
source share
1 answer

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; 
+10
source

Source: https://habr.com/ru/post/1346748/


All Articles