1

我正在尝试使用 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");
        }
    }
}

它有这样的东西:

在此处输入图像描述

但我需要这个:

在此处输入图像描述

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

4

0 回答 0