views:

2330

answers:

5

I can already populate the data into the spreadsheet, create the chart based on the range I select. However, when it comes to formatting the actual chart I feel a bit lost as their are so many options!!

It is an xlCylinderBarStacked type chart. I simply need to make the color of the bars a nice light orange and make the background a light blue fading into white at the bottom.

Any idea's how to do this?

A: 

One good trick with Excel and other VBA-enabled apps is to manually create the formatting/content you require using the Excel GUI, whist recording a 'macro'. Once this is done you can then inspect the generated VBA to see how to use the API to acheive the same results programmatically. You will of course have to do some translation from VBA to C# but essentially the same methods should work.

AdamRalph
A: 

Hi, tried this, doesnt show formatting of a graph in terms of applying a background gradient etc.

James
If it can't be done via the UI then it probably can't be done programatically either.
AdamRalph
Hi, it can actually be done as their are a hell of a lot of properties etc that relate to it. My problem is I am unsure what order/values they will require. Can't seem to figure it out. Also, I read, apparently only some properties work for specific graphs which confuses it even further!
James
A: 

Thanks for the references bolt.

However, I really do need the formatting to be done before I move onto exporting the chart. Anyone have any idea's as to how I can go about doing this in C#?

I am able to change the color of the bars now, just need to figure out what color it is I need. Also, I can actually get the background of the chart to change color, but I need it to be a linear gradient effect i.e. light blue fading into white at the bottom.

James
It's better if you use comments or edits to your original question to respond answers, rather than posting more answers yourself
AdamRalph
Hi, sorry quite new to this site! Will do in the future
James
+1  A: 

Just to close this question off. I played around a little with the properties and the following achieved the gradient effect on the background of the chart.

xlChart.Interior.Color = ColorTranslator.ToOle(Color.LightSkyBlue);
chart.ChartArea.Fill.TwoColorGradient(
       Microsoft.Office.Core.MsoGradientStyle.msoGradientHorizontal, 
       1);
James