Format Excel Chart Background using C#

混江龙づ霸主 提交于 2019-12-11 10:16:40

问题


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?


回答1:


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);



回答2:


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.



来源:https://stackoverflow.com/questions/702765/format-excel-chart-background-using-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!