我有这个代码:
private void WriteChartSheet()
{
_xlSheetChart = (Worksheet)_xlSheets.Item[2];
if (_xlSheetChart != null)
{
_xlSheetChart.Name = ProduceUsageChartSheetName;
// Contract vs. non-Contract pie chart
_xlSheetChart.Cells[1, 1] = "Contracted Items";
_xlSheetChart.Cells[1, 2] = "Non-Contracted Items";
_xlSheetChart.Cells[2, 1] = GetContractedItemsTotal();
_xlSheetChart.Cells[2, 2] = GetNonContractedItemsTotal();
ChartObjects xlCharts = (ChartObjects)_xlSheetChart.ChartObjects(Type.Missing);
ChartObject contractChartObject = xlCharts.Add(0, 0, 300, 250); // left, top, width, height
Chart contractChart = contractChartObject.Chart;
Range chartRange = _xlSheetChart.get_Range("A1", "B2");
contractChart.SetSourceData(chartRange, Missing.Value);
contractChart.ChartType = XlChartType.xlPie; //xl3DPie;
contractChart.ApplyDataLabels(XlDataLabelsType.xlDataLabelsShowValue, XlDataLabelsType.xlDataLabelsShowLabel, true, false, false, true, false, true);
. . .
...产生这个饼图:
我非常喜欢它,但我也需要在饼图块中印上价值(例如“合同项目”部分的“361,779 美元”,以及其他部分的适当价值)。我怎样才能做到这一点?