PC Review


Reply
Thread Tools Rate Thread

Color Mismatch from System.Drawing.Color

 
 
=?Utf-8?B?UmVtaUBuZXdzZ3JvdXBzLm5vc3BhbQ==?=
Guest
Posts: n/a
 
      11th Oct 2007
Hi,
i setting the interior color of a cell in excel from a C# code and when i
see the result in excel the color is not matching. The color i start from is
RED and the result in the produced Excel document is BLUE.

My question is, how do i set the Color property of the interior of a cell
from a System.Drawing.Color instance... Here is what i tried...

Microsoft.Office.Interop.Excel.Range rng = sheet.Cells[Row, Col] as
Microsoft.Office.Interop.Excel.Range;
rng.Interior.Color = (interiorCellColor.Value.R << 16) |
(interiorCellColor.Value.G << 8) | interiorCellColor.Value.B;

I also tried the ToArgb method with the same result...

I will take any theory explaining the difference in color from what i start
from and the result in excel.

Remi
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmVtaUBuZXdzZ3JvdXBzLm5vc3BhbQ==?=
Guest
Posts: n/a
 
      11th Oct 2007
Ok, i think i got it:
rng.Interior.Color = (interiorCellColor.Value.B << 16) |
(interiorCellColor.Value.G << 8) | interiorCellColor.Value.R;

I think i just misplaced the values, which definitely dont make much sense
to me anyway...

Any comments ?

"(E-Mail Removed)" wrote:

> Hi,
> i setting the interior color of a cell in excel from a C# code and when i
> see the result in excel the color is not matching. The color i start from is
> RED and the result in the produced Excel document is BLUE.
>
> My question is, how do i set the Color property of the interior of a cell
> from a System.Drawing.Color instance... Here is what i tried...
>
> Microsoft.Office.Interop.Excel.Range rng = sheet.Cells[Row, Col] as
> Microsoft.Office.Interop.Excel.Range;
> rng.Interior.Color = (interiorCellColor.Value.R << 16) |
> (interiorCellColor.Value.G << 8) | interiorCellColor.Value.B;
>
> I also tried the ToArgb method with the same result...
>
> I will take any theory explaining the difference in color from what i start
> from and the result in excel.
>
> Remi

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Font.Color to System.Drawing.Color in C# Andrew HUANG Microsoft Excel Programming 0 9th Jan 2008 07:01 PM
convert RGB color to System.Drawing.Color? =?Utf-8?B?UmljaA==?= Microsoft VB .NET 3 28th Apr 2005 12:23 AM
How do I convert from a 'double' valued color to a System.Drawing.Color? Nat Microsoft Excel Programming 11 28th Jun 2004 01:28 AM
System.Drawing.Color Andy Janssen Microsoft Dot NET Framework 1 24th Oct 2003 10:40 PM
System.Drawing.Color PCH Microsoft Dot NET Compact Framework 8 16th Oct 2003 06:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.