Spreadsheetlight饼图

时间:2015-04-27 04:56:41

标签: c# asp.net-mvc excel model-view-controller

如何使用电子表格光在饼图上显示百分比?

这是我目前的代码

        double fChartHeight = 15.0;
        double fChartWidth = 7.5;

        SLChart chart;

        chart = sl.CreateChart("N1", "R2");
        chart.SetChartType(SLPieChartType.Pie);
        chart.SetChartPosition(piechartRow, 0, piechartRow + fChartHeight, fChartWidth);
        chart.Title.Shadow.SetPreset(SpreadsheetLight.Drawing.SLShadowPresetValues.PerspectiveDiagonalUpperLeft);              
        sl.InsertChart(chart);

        sl.SaveAs(path);

1 个答案:

答案 0 :(得分:1)

不确定您正在寻找什么,但希望这能让您朝着正确的方向前进。

    double fChartHeight = 15.0;
    double fChartWidth = 7.5;

    SLChart chart;

    chart = sl.CreateChart("N1", "R2");
    chart.SetChartType(SLPieChartType.Pie);
    chart.SetChartPosition(piechartRow, 0, piechartRow + fChartHeight, fChartWidth);
    chart.Title.Shadow.SetPreset(SpreadsheetLight.Drawing.SLShadowPresetValues.PerspectiveDiagonalUpperLeft);

    SLGroupDataLabelOptions grplabels = chart.CreateGroupDataLabelOptions();
    grplabels.ShowPercentage = true;
    grplabels.ShowValue = false;
    chart.SetGroupDataLabelOptions(grplabels);

    sl.InsertChart(chart);

    sl.SaveAs(path);

如果要调整单个数据标签,请使用SLDataLabelOptions类。基本上,想象一下你在Excel中是如何做到的。实际上,请在Excel中制作饼图。将饼图格式化为您想要的外观。使用SpreadsheetLight复制您在Excel中执行的步骤。