Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Sep 29, 2022 8:56 pm

Hi, I'm generating a chart (ColumnStacked) in an Excel spreadsheet using Spire.XLS in C#, but I would like to know how to insert the values ​​in the columns, as shown in the images below.

Could anyone help me?

Thanks
Attachments
grafico2.jpg
How I would like
grafico2.jpg (70.59 KiB) Viewed 476 times
grafico1.jpg
My current chart
grafico1.jpg (107.85 KiB) Viewed 476 times

evilarinho
 
Posts: 1
Joined: Thu Sep 29, 2022 8:50 pm

Fri Sep 30, 2022 7:11 am

Hello,

Thanks for your inquiry.
You can refer to my code below to assign values to columns. If there is still any issue after testing, please provide us with your test code and test documentation for further investigation. You can attach it here or send it via email(support@e-iceblue.com).
Code: Select all
            //Create a workbook
            Workbook workbook = new Workbook();
            workbook.Version = ExcelVersion.Version2013;
            //Get the first sheet
            Worksheet sheet = workbook.Worksheets[0];
            //Set value of specified range
            sheet.Range["A1"].Value = "1";
            sheet.Range["A2"].Value = "2";
            sheet.Range["A3"].Value = "3";
            sheet.Range["B1"].Value = "4";
            sheet.Range["B2"].Value = "5";
            sheet.Range["B3"].Value = "6";
            sheet.Range["C1"].Value = "7";
            sheet.Range["C2"].Value = "8";
            sheet.Range["C3"].Value = "9";
            Chart chart = sheet.Charts.Add(ExcelChartType.ColumnStacked);
            chart.DataRange = sheet.Range["A1:C3"];
            chart.TopRow = 4;
            chart.LeftColumn = 2;
            chart.Width = 450;
            chart.Height = 300;
            foreach (ChartSerie cs in chart.Series)
            {
                cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
                cs.DataPoints.DefaultDataPoint.DataLabels.ShowLeaderLines = true;
            }
            workbook.SaveToFile("Output.xlsx", ExcelVersion.Version2013);


Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Sat Oct 08, 2022 2:14 am

Hello,

Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.XLS