Click here to Skip to main content
12,953,652 members (45,846 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
int rows = darray.GetUpperBound(0);
int cols = darray.GetUpperBound(1);
for (int i = 1; i <= rows; i++)
{
    for (int j = 1; j <= cols; j++)
    {
        workSheet_range = mySheet.get_Range(i, j);
        if (workSheet_range.Interior.Color == System.Drawing.Color.Red)
        {
             kauntalda++;
        }
    }
}

Not working!
Posted 18-Sep-12 2:47am
Radzhab1.2K
Updated 18-Sep-12 3:17am
v4
Comments
Andrei Straut 18-Sep-12 8:52am
   
Not here for long
Radzhab 18-Sep-12 9:22am
   
???
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

//....
workSheet_range = mySheet.get_Range(i, j); 
if(workSheet_range.Interior.Color == System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
{
// your stuff goes here
}
/....
  Permalink  
Comments
Radzhab 19-Sep-12 1:34am
   
workSheet_range = mySheet.get_Range(i, j); this code returns null



var usedRange = mySheet.UsedRange;
object[,] darray = null;
darray = (object[,]) usedRange.Value;

int rows = darray.GetUpperBound(0);
int cols = darray.GetUpperBound(1);
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= cols; j++)
{
workSheet_range = mySheet.get_Range(i, j); // return null
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

To get or set a color for cell background, you can use ColorIndex[^] property too.
//chack for white
if(workSheet_range.Interior.ColorIndex == 2)
{
// ... ;)
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100