I create Pie Chart in VS 2008 C# Project using Microsoft Office Interop Excel.
The code is:
Excel.Chart xlChart = (Excel.Chart)xlWorkBook
.Charts
.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Excel.Range xlDataRange = xlWorkSheet
.get_Range(xlWorkSheet.Cells[
nDataForDiagramRow - alToExcelInvestmentGroupNames.Count,
_nColumnsCount - 3
],
xlWorkSheet.Cells[
nDataForDiagramRow - 1,
_nColumnsCount - 2
]);
xlChart.ChartType = Excel.XlChartType.xl3DPieExploded;
xlChart.Elevation = 60;
xlChart.Rotation = 130;
xlChart.SetSourceData(xlDataRange, Type.Missing);
xlChart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowLabelAndPercent,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);
xlChart.Location(Excel.XlChartLocation.xlLocationAsObject, xlWorkSheet.Name);
With method xlChart.ApplyDataLabels I make Labels and Percentage visible, but Percentage is Rounded.
How to access the format of label to show fractional part of percentage?
I’ve founded the solution myself.
nLabelis int number of label in collection of labels in chart.