PC Review


Reply
Thread Tools Rate Thread

Color a range with different colors

 
 
Magnus.Moraberg@gmail.com
Guest
Posts: n/a
 
      26th Mar 2008
Hi,

I'd like to do something like this -

int[,] colorMatrix = { { System.Drawing.Color.Yellow.To ToArgb(),
System.Drawing.Color.Red.ToArgb() },
{ System.Drawing.Color.Green.ToArgb(),
System.Drawing.Color.Blue.ToArgb() } };

range = worksheet.get_Range(worksheet.Cells[1, 1], worksheet.Cells[2,
2]);

range.Interior.Color = colorMatrix;

But it doesn't work. Instead I just get one color in all cells. Is it
possible to set a range with different colors? It works for text as
follows -

string[,] textMatrix = { { "A","B" }, { "C", "D" } };

range = worksheet.get_Range(worksheet.Cells[1, 1], worksheet.Cells[2,
2]);

range.Value2 = textMatrix;

The reason I wish to fill a range is that setting the value of a
single cell is really slow when you do it for a large number of cells.
As follows -

for(int i = 1; i<=10000; i++)
worksheet.Cells[i,1] = "A"; // really slow

Any suggestions?

Barry.



 
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
How to Color a Cell Based on a Range of Cells with Colors ron weasley Microsoft Excel Worksheet Functions 1 13th Jan 2010 01:05 AM
Re: Color laser printer prints colors much darker than screen colors John McGaw Computer Hardware 0 27th Jan 2009 01:24 AM
Re: Color laser printer prints colors much darker than screen colors John McGaw Computer Hardware 0 24th Jan 2009 10:24 PM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM
Color fill doesn't let you select a color. Colors greyed out. =?Utf-8?B?RGlhbmU=?= Microsoft Word Document Management 4 28th Nov 2005 07:19 AM


Features
 

Advertising
 

Newsgroups
 


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