In a VSTO C# project I want to get a range of rows from a set of row indexes.
The row indexes can be for example like \"7,8,9,12,14\".
Then I want the range
This code assign color to range cells based on criteria:
using Microsoft.Office.Interop.Excel;
(...)
var excel = new Application { Visible = true };
Workbook workbook = excel.Workbooks.Add(XlSheetType.xlWorksheet);
Worksheet sheet = workbook.Sheets[1];
var i = 2;
foreach (Data d in this.Datos)
{
sheet.Cells[i, 1].Value = d.Fecha;
sheet.Cells[i, 2].Value = d.Ubicacion;
sheet.Cells[i, 3].Value = d.Lote;
sheet.Cells[i, 4].Value = d.ArticuloId;
sheet.Cells[i, 5].Value = d.Articulo;
sheet.Cells[i, 6].Value = d.ColorId;
sheet.Cells[i, 7].Value = d.Color;
sheet.Cells[i, 8].Value = d.StockOriginal;
sheet.Cells[i, 9].Value = d.Diferencia;
sheet.Cells[i, 10].Value = d.StockFinal;
if (d.BackGroundColor == "#FFA061")
sheet.Range[sheet.Cells[i, 1], sheet.Cells[i, 10]].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.FromArgb(255, 160, 97));
i++;
}