c# Excel Pie Chart Custom Color -


how create custom color on excel pie chart? pie chart has 5 slice. below source code.

using excel = microsoft.office.interop.excel; excel.range chartrange;  excel.chartobjects xlcharts = (excel.chartobjects)xlworksheet.chartobjects(type.missing); excel.chartobject mychart = (excel.chartobject)xlcharts.add(10, 80, 500, 350); excel.chart chartpage = mychart.chart;  chartrange = xlworksheet.get_range("a3", "b7");             chartpage.chartstyle = 209; chartpage.hastitle = true; chartpage.charttitle.text = "headertext title"; chartpage.setsourcedata(chartrange, misvalue);             chartpage.charttype = excel.xlcharttype.xl3dpieexploded; chartpage.elevation = 35; chartpage.applydatalabels(excel.xldatalabelstype.xldatalabelsshowlabelandpercent ,false, true, true, false, true, false, true, true, separator:system.environment.newline);  xlworkbook.saveas(saveaslocation); xlworkbook.close(true, misvalue, misvalue); xlapp.quit(); 

you can change colorindex of each point of pie chart this:

var series = (excel.seriescollection)chartpage.seriescollection(); series.item(1).points(1).interior.colorindex = 3; //red series.item(1).points(2).interior.colorindex = 4; //green series.item(1).points(3).interior.colorindex = 5; //blue series.item(1).points(4).interior.colorindex = 6; //yellow series.item(1).points(5).interior.colorindex = 7; //magenta 

here full list of available colors msdn

the colorindex property can have valid integer arguments between 0 , 56 generate color.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -