Provide the C#.Net sample code to create chart

Thank you. Please update once it is resolved. image.png (51.3 KB)

Please provide the C#.Net sample code to achive the attached exact chart. So that we will use the aspose excel code and convert it into pdf.

image.png (51.3 KB)

Please provide the C#.Net sample code to achive the attached exact chart. So that we will use the aspose excel code and convert it into pdf.

How to specify the colors for each bar in the chart?

We required similar barchart output with color for the attached sample data. Kindly provide the code to display the exact chart which is attached. image.png (51.3 KB)

@mvmuthukumar,

Please create your desired sample chart in MS Excel manually and save the file. Zip the Excel file and attach it here, we will check and help you through.

AposeTestPdfoutput.zip (8.6 KB)

Please find the sample excel with chart. But we are not getting the similar color and if the value is 0 then Bar is not coming. Please verify and provide the code image.png (51.3 KB)

@mvmuthukumar,

Thanks for the Excel file.

You have not provided your desired chart in sample Excel file. Anyways, I have written the sample code to create your desired chart in the output Excel file. See the following sample code to accomplish the task. I have used source data (for the chart) from your provided Excel file and created another chart in the same sheet. Please refer to it and write/update your code by yourselves for your custom needs:
e.g.
Sample code:

           Workbook workbook = new Workbook("e:\\test2\\AposeTestPdfoutput.xls");
           Worksheet sheet = workbook.Worksheets[0];
           
           
           //Generate the second chart
           int chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column3DClustered, 21, 0, 43, 17);
           Chart chart = sheet.Charts[chartIndex];

           //Insert series
           chart.NSeries.Add("B2:H2",false);
           chart.NSeries.CategoryData = "B1:H1";
           chart.NSeries.IsColorVaried = true;

           chart.ShowLegend = true;

           workbook.Save(@"e:\test2\out1.xlsx");

Hope, this helps a bit.

Thanks for your reply. We will try and update on the status. If there is not data i.e the value is 0 then how to display the bar with 0 value

@mvmuthukumar,

If you could find some time to try my sample code to generate the file. Now open the file and you will see that the generated chart in the sheet also has bars for “0” value.

Thanks. We will test and update you.