2

I'm trying to create a column chart using the SpreadSheetLight library. Here is my code

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");
        }
    }
}

It have got something like this:

enter image description here

But I need this:

enter image description here

How can I customize my column chart view using SpreadSheetLight?

Yared
  • 2,206
  • 1
  • 21
  • 30
r00xus
  • 79
  • 6
  • Removing SetChartType call and adding below chart via below method did what I wanted. chart.PlotDataSeriesAsSecondaryLineChart(2, SLChartDataDisplayType.Normal, false); – John Mar 10 '22 at 10:28

0 Answers0