SpreadSheetLight柱形图

时间:2017-11-26 13:16:39

标签: c# spreadsheetlight

我正在尝试使用SpreadSheetLight库创建柱形图。这是我的代码

using System;
using SpreadsheetLight;
using SpreadsheetLight.Charts;

namespace TestSpreadSheetLight
{
    class Program
    {
        static void Main(string[] args)
        {
            SLDocument sl = new SLDocument();

            for (int i = 1; i <= 5; i++)
                sl.SetCellValue(1, i, "Item" + i.ToString());

            Random rand = new Random();
            for (int i = 1; i <= 5; i++)
                sl.SetCellValue(2, i, Convert.ToInt32(rand.NextDouble() * 10));

            double fChartHeight = 15.0;
            double fChartWidth = 7.5;

            SLChart chart;

            chart = sl.CreateChart(1, 1, 2, 5);
            chart.SetChartType(SLColumnChartType.ClusteredColumn);
            chart.SetChartPosition(4, 0, 4 + fChartHeight, fChartWidth);
            sl.InsertChart(chart);

            sl.SaveAs("ChartsColumn.xlsx");
            System.Diagnostics.Process.Start("ChartsColumn.xlsx");
        }
    }
}

它有这样的东西:

enter image description here

但我需要这个:

enter image description here

如何使用SpreadSheetLight自定义柱形图视图?

0 个答案:

没有答案