((Excel.Range)sheet.Cells[row, column]).Interior.Color =
m_backgroundColor.ToArgb();
However features such as the conditional formatting options seem to be able
to render colors on smooth scales without impacting the standard color
pallette.
Is there any way to manipulate the color attributes using accurate color
mapping?
The following function returns a valid Office color from a .Net color.
/// <summary>
/// Returns an Excel color from a .Net color
/// </summary>
/// <param name="netColor">Color</param>
/// <returns>int</returns>
public static int GetExcelColor(Color netColor)
{
string hexVal = netColor.B.ToString("x").PadLeft(2, '0') +
netColor.G.ToString("x").PadLeft(2, '0') +
netColor.R.ToString("x").PadLeft(2, '0');
return int.Parse(hexVal,
System.Globalization.NumberStyles.HexNumber);
}
There may of course be a more elegant way to handle this...