Wednesday, July 02, 2008
C# to Excel Interop Color Bug
I'm rewriting my SQL documenter in C# 3.0 and came across a bug with Excel interop. I need to set the background color of some cells to light yellow, but when I use this code:
curRange.Interior.Color = Color.LightYellow.ToArgb();it comes out as light cyan. I tried Color.Yellow and it comes through as Cyan. The solution is to use Cyan:
curRange.Interior.Color = Color.LightCyan.ToArgb();to get light yellow. I added a comment to the code about why the colors are reveresed.
Comments:
Links to this post:
<< Home
I am not sure how to see your comments, so I would be very interested in knowing why the colors are messed up, and how to correct it.
Thanks in advance,
Ben
Thanks in advance,
Ben
Ben, just switch the colors as I stated in the post. Then yellow comes out yellow and cyan comes out cyan.
How do I calculate what to switch for other colors? I.E. I want the color wheat, but it comes out as a blue, etc. How do you calculate how to get the correct color?
I just switched the colors. I wanted yellow, but it came out cyan, so I switched them and it worked. You should trye bue, or some shade of blue to see if it works.
Ok, thanks. So if I understand correctly there is no real way of knowing what the color will turn out as. It's just kind of a "test and see what you get" scenario. I was hoping that there was some logic or mapping to tell me ahead of time what to try. Thanks for you help on this.
Also, I understand you are part of the Utah County code group. Any idea if there is a group up here in Cache Valley?
Ben
Also, I understand you are part of the Utah County code group. Any idea if there is a group up here in Cache Valley?
Ben
I attend the group in Salt Lake. There is no group in Cache Valley. The closest one to you is Davis county.
Post a Comment
Links to this post:
<< Home
Subscribe to Posts [Atom]

