Color a range with different colors
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. |
All times are GMT +1. The time now is 03:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com