How to compare color

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
First i generate spread sheet excel file by EPPlus library where i set background color for few cell like this way by EPPlus library.


using (var range = worksheet.Cells[rownumber + 1, columnIndex + 1])
{
range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(Color.Olive);
range.Style.ShrinkToFit = false;
}



after generating spread sheet by EPPlus the same file load into dev express spread sheet control. where i need to check cell background color is olive. i did it this way but the same code some time not working.


//dgvReport is spreadsheet control of devexpress
DevExpress.Spreadsheet.IWorkbook workbook = dgvReport.Document;
DevExpress.Spreadsheet.Worksheet sheet = workbook.Worksheets[0];

if (sheet[clickedRow, clickedColumn].Fill.BackgroundColor == Color.Olive)
{
sheet[clickedRow, clickedColumn].Fill.BackgroundColor = Color.Empty;
sheet[clickedRow, clickedColumn].Borders.SetAllBorders(Color.Empty, DevExpress.Spreadsheet.BorderLineStyle.None);
}



so please tell me my above code where i am comparing color is right ? i first set background color by EPPlus and later comparing the color
by dev express spread sheet control like this way if (sheet[clickedRow, clickedColumn].Fill.BackgroundColor == Color.Olive)

is it right code ? if i am wrong then please rectify my code.

i am not asking any question specific to Devexpress. it is all about color. One guy said To compare two colors, it is better to use their ARGB representation (Color.ToArgb)

Compare two Color objects

looking for a sample code where i will use ARGB representation for color comparision. please help

Continue reading...
 
Back
Top