We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Comparision bar charts .net

Hi,


Please see the attached image. how we can create this type of comparison chart year wise in aspose.cells .net.
Please let me know


Thanks
Noopur

Hi,


Please create your desired chart in MS Excel manually and save the Excel file to provide us here, we will check how to do it via Aspose.Cells APIs.

Thank you.

Hi,


I have created this chart in excel now please let me know how to create this by using aspose.cells.
Iam able to create the data like this with aspose.but not able to create chart like this.
Please send me the code.

Find the attached excel

Hi,

Thanks for your posting and using Aspose.Cells.

Please see the following code to create this chart. I have also attached the output xls file generated by the code for your reference. I used the latest version: Aspose.Cells
for .NET v8.6.1.1
to generate this chart.

C#
string filePath = @“D:\Downloads\Comparison.xls”;

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[0];

int idx = worksheet.Charts.Add(ChartType.Column, 10, 10, 30, 30);
Chart ch = worksheet.Charts[idx];
ch.SetChartDataRange(“A1:C7”, true);

workbook.Save(“output.xls”);

hi,


thanks but can you please send me the code for version 7.7 how to do it by adding data in nserier and category data.
becoause SetChartDataRange dosnt work in version 7

Please send me the code like this- /

chart.NSeries.Add(“Data!B1:C1”, false);

chart.NSeries.CategoryData = “Data!A2:A7”;

Hi,


See the sample updated code segment for your reference for your requirements:
e.g
Sample code:

string filePath = @“e:\test2\Comparison.xls”;

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[0];

//Create chart
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 1, 29, 10);
Chart chart = worksheet.Charts[chartIndex];

//Add the nseries collection to a chart
chart.NSeries.Add(“B2:C7”, true);
//Get or set the range of category axis values
chart.NSeries.CategoryData = “A2:A7”;
chart.NSeries.IsColorVaried = true;

for (int i = 0; i < chart.NSeries.Count; i++)
{
chart.NSeries[i].Name = worksheet.Cells[0, i+1].Value.ToString();
}



workbook.Save(“e:\test2\output1.xls”);


Hope, this helps a bit.

Thank you.