我使用 Microsoft Office Interop Excel 在 VS 2008 C# 项目中创建饼图。
代码是:
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);
使用方法xlChart.ApplyDataLabels
我使标签和百分比可见,但百分比是四舍五入的。
如何访问标签的格式以显示百分比的小数部分?