Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Link is there
Second link is there

What I have tried:

I want to change from blue to white color.Like in the pictures.
Posted
Updated 10-Feb-16 21:56pm
v2
Comments
dan!sh 11-Feb-16 3:21am    
You just said what you want in what you have tried. What have you tried? Anything?
Maciej Los 11-Feb-16 3:24am    
Not a question at all!
What's the problem?
ibrahim-34 11-Feb-16 3:56am    
I have two links up there.you can look at them.I want to change backcolorof worksheet ,ı tryed but i cant i need help on this.

Excel.Style style = Globals.ThisWorkbook.Styles.Add("NewStyle", missing);
style.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
style.Interior.Pattern = Excel.XlPattern.xlPatternSolid;
Microsoft.Office.Tools.Excel.NamedRange rangeStyles = this.Controls.AddNamedRange(this.Range["A1", missing], "rangeStyles");
rangeStyles.Style = "NewStyle";
rangeStyles.Columns.AutoFit();


Using C# code to change the background color of an Excel spreadsheet range[^]

try below
.net - Change the background of Cells with C# - Stack Overflow[^]
 
Share this answer
 
v2
Comments
ibrahim-34 11-Feb-16 3:54am    
Thank you ,all of them working but in the first link ı can change only font and in the second ı can change cells, i want change all backcolor worksheet not only one line.Like in the link of picture.How can i change Rows backcolor?
 
Share this answer
 
Comments
ibrahim-34 11-Feb-16 3:55am    
Thank you for answer, but i want change all backcolor worksheet ,or if it is possible to change Rows backcolor.Like in the link of picture.
Maciej Los 11-Feb-16 4:46am    
Excel doesn't contain "Line" object! Don't be lazy! Try to adapt code to your needs.
I think Excel does not have any option to change a worksheet background color. There are 2 possible ways to archieve this I can think of:

- Select all Cells and change their Color
- Create in a graphics program a rectangle in the desired color, and then select it as the sheet background
 
Share this answer
 
v2
Comments
ibrahim-34 11-Feb-16 4:45am    
Thank you for answer , but i try to do in the c#.I can changed cells but i try to change Rows and i get error.If i can change Rows backcolor , i think i can find solution.
Pikoh 11-Feb-16 4:51am    
Ibrahim, you've been just told how to apply color to a range of cells, so you can change a Row backcolor.
Maciej Los 11-Feb-16 4:48am    
First way is OK, but second may provide unexpected file growth - i do not recommend it.
Pikoh 11-Feb-16 4:51am    
Well, i don't think it grows a lot. It's just a small jpg added and i think excel would just tile it, but i never tried it.
Maciej Los 11-Feb-16 4:54am    
I didn't say that "file will grow", i said: "it may provide growth". It's not the same.
Thank you everybody,I find the solution !

C#
range.EntireColumn.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900