Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Color Mismatch from System.Drawing.Color

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Color Mismatch from System.Drawing.Color

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 ?

" 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing toolbar: line color button hammonl Excel Discussion (Misc queries) 1 August 25th 09 03:25 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Pivot Tables Formatting interior color &Type Mismatch CraigS Excel Programming 0 January 8th 05 07:45 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM
How do I convert from a 'double' valued color to a System.Drawing.Color? Nat[_3_] Excel Programming 11 June 28th 04 01:28 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"