I need a to create a chart with the same format of the attached the excel (Charts_Test.xlsx) i am wrting a code but that is not working as expected can help to achive the same attached the my code file .Even i set the CategoryData to the columns the sill it is coming serier1,series2,series3,series4 instead of D+1,D+2,D+3,D+4-6 .Please help me where i am wrong. i am new charts thanks in adavance
Hi,
Thanks for your posting and using Aspose.Cells.
I have created the similar chart as given by you in your source excel file using the following code with the latest version: Aspose.Cells for .NET (Latest Version) .
I have attached the output excel file generated by this code for your reference. Please check the sheet named Chart2.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\Charts_Test.xlsx”;
Workbook workbook = new Workbook(filePath);
int idx = workbook.Worksheets.Add(SheetType.Chart);
Worksheet worksheet = workbook.Worksheets[idx];
idx = worksheet.Charts.Add(ChartType.Column100PercentStacked, 10, 10, 18, 18);
Chart ch = worksheet.Charts[idx];
ch.SetChartDataRange(“=Sheet1!$B$3:$J$6”, false);
ch.NSeries.CategoryData = “=Sheet1!$C$1:$J$2”;
workbook.Save(“output.xlsx”);
Hi
Hi,
Thanks for your feedback and using Aspose.Cells.
We will look into it and provide you a solution with v8.4.0 so that you could continue to use the older version as per your needs.
Hi,
Thanks for using Aspose.Cells.
Please see the following sample code that is runnable with v8.4.2 and it does not use chart.SetChartDataRange method.
I have attached the source excel file used in this code and the output excel file generated by it for your reference.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;
Workbook workbook = new Workbook(filePath);
int idx = workbook.Worksheets.Add(SheetType.Chart);
Worksheet worksheet = workbook.Worksheets[idx];
idx = worksheet.Charts.Add(ChartType.Column100PercentStacked, 10, 10, 18, 18);
Chart ch = worksheet.Charts[idx];
ch.NSeries.Add("=Sheet1!$C$3:$J$6", false);
ch.NSeries[0].Name = “=Sheet1!$B$3”;
ch.NSeries[1].Name = “=Sheet1!$B$4”;
ch.NSeries[2].Name = “=Sheet1!$B$5”;
ch.NSeries[3].Name = “=Sheet1!$B$6”;
ch.NSeries.CategoryData = “=Sheet1!$C$1:$J$2”;
workbook.Save(“output.xlsx”);
Thanks for the help it worked
Hi Sarulatha,