Reputation: 2469
I want to select a range of cells Using Excel Interop C# in which background color is "LightBlue".? How do I do that.
Upvotes: 1
Views: 667
Reputation: 1030
Try
Microsoft.Office.Interop.Excel._Worksheet worksheet;
int endColumn = 16384;
int endRow = 65536;
var results= new List<Excel.Range>();
for(var i=0;i<=endColumn;i++)
{
for(var j=0;j<=endRow;j++)
{
if(worksheet.Cells[j,i].Interior.Color == System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightBlue))
{
result.Add(worksheet.Cells[j,i]);
}
}
}
Upvotes: 2