Hi,
Thanks for your query.
Please see the sample code below for your needs for your reference:
e.g
Sample code:
//Create a new Workbook.
Workbook workbook = new Workbook();
//Add a chart sheet.
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
Worksheet sheet = workbook.Worksheets[sheetIndex];
//Set the name of worksheet
sheet.Name = “Chart”;
//Create chart
int chartIndex = 0;
chartIndex = sheet.Charts.Add(ChartType.Pie, 1, 1, 25, 10);
Chart chart = sheet.Charts[chartIndex];
chart.NSeries.Add("{10,20,30,40}", true);
chart.NSeries.CategoryData = “{“sdf”,“sdf1”,“sdf2”, “sdf3”}”;
chart.NSeries.IsColorVaried = true;
//Set the DataLabels in the chart
DataLabels datalabels;
for (int i = 0; i < chart.NSeries.Count; i++)
{
datalabels = chart.NSeries[i].DataLabels;
datalabels.Position = LabelPositionType.InsideBase;
datalabels.ShowCategoryName = true;
datalabels.ShowPercentage = true;
}
//Save the excel file
workbook.Save(“e:\test2\out1.xlsx”);
Hope, this helps a bit.
Thank you.