Pie in the Sky, not in your Eye
This assumes you are using Excel Interop to work with Excel in a C# app.
Creating a pie chart is as easy as generating some data for it, and adding the chart to a worksheet:
using System.Runtime.InteropServices;
using Excel = Microsoft.Office.Interop.Excel;
. . .
private Excel.Worksheet _xlSheet;
. . .
object misValue = System.Reflection.Missing.Value;
_xlSheet.Cells[12, 11] = "Apple";
_xlSheet.Cells[12, 12] = "100";
_xlSheet.Cells[12, 13] = "167";
_xlSheet.Cells[12, 14] = "67";
_xlSheet.Cells[13, 11] = "Cherry";
_xlSheet.Cells[13, 12] = "78";
_xlSheet.Cells[13, 13] = "72";
_xlSheet.Cells[13, 14] = "96";
_xlSheet.Cells[14, 11] = "Gooseberry";
_xlSheet.Cells[14, 12] = "182";
_xlSheet.Cells[14, 13] = "185";
_xlSheet.Cells[14, 14] = "165";
_xlSheet.Cells[15, 11] = "Blackberry";
_xlSheet.Cells[15, 12] = "189";
_xlSheet.Cells[15, 13] = "180";
_xlSheet.Cells[15, 14] = "165";
_xlSheet.Cells[16, 11] = "Strawberry-Rhubarb";
_xlSheet.Cells[16, 12] = "17";
_xlSheet.Cells[16, 13] = "18";
_xlSheet.Cells[16, 14] = "16";
Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)_xlSheet.ChartObjects(Type.Missing);
Excel.ChartObject chartObj = (Excel.ChartObject)xlCharts.Add(468, 160, 348, 268);
Excel.Chart chart = chartObj.Chart;
chartRange = _xlSheet.Range[_xlSheet.Cells[12, 11], _xlSheet.Cells[16, 14]];
chart.SetSourceData(chartRange, misValue);
chart.ChartType = Excel.XlChartType.xlExplodedPie;
chart.HasTitle = true;
chart.ChartTitle.Text = "Favorite Pies";
...and then adding the following line to add the labels:
chart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowPercent, Excel.XlDataLabelsType.xlDataLabelsShowLabel, true, false, false, true, false, true);
And "Voila!" as the eaters of escargot pie are wont to say: you now have a wonderfully splendiferous and scrumptious pie chart (shown before the title was added and the legend was removed):
If the Legend is only a Legend in its Own Mind
If labeling the pie pieces is enough, and you don't need the legend, you can add this line of code to prevent the legend from displaying:
chart.HasLegend = false;
I recently discovered Spreadsheet Light, which seems to greatly simplify and elegantize the creation of Excel spreadsheets with C#; soon, I will post an "alternate universe" version of this article about creating a chart with Spreadsheet Light.
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).
Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.
I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven