I am unable set Cell range to chart.nseries.categorydata

Hi Team,

I am unable set Cell range to chart.nseries.categorydata field.
i am assigning as below
chart.NSeries.CategoryData = (reportSheetName + “!B20:B” + (exportData.DataTable.Tables[0].Rows.Count + 19));

but still it nor assigned to CategoryData . I am using Aspose.cells 18.4.0.0 version

can u tell how can i set excel data range to CategoryData .

thanks,
Kiran

@kiranreddy0228,

Thanks for providing us some details.

Well, the issue might be on your end or in your code. Please check individual variables and objects data if these have correct values, e.g reportSheetName, exportData.DataTable.Tables[0].Rows.Count, etc. You may even try some hard coded values to directly assign for CategoryData attribute.

If you still think it is an issue with Aspose.Cells APIs, kindly do create a simple console application (runnable) and post us (you may zip the project prior attaching) to reproduce the issue on our end, we will check it soon. Please remove any inter dependencies for external database or external sources and use/create DataTable in code (if necessary), so we could evaluate your issue precisely to consequently figure it out soon.

Old versions it is working fine .Recently we upgraded to Aspose.cells 18.4.0.0 version from this version it is not assignable to CategoryData.

@kiranreddy0228,

We do not evaluate issue in older version. Please try our latest version/fix: Aspose.Cells for .NET v19.1.x, it should work fine. If you still find the issue with v19.1.x, as requested earlier, kindly do create a simple console application (runnable) and post us (you may zip the project prior attaching) to reproduce the issue on our end, we will check it soon.

Hi Team,
I am Attaching Sample console Application. In this issue reproduced. I found the issue in

Exceltasks.cs line no- 299
chart.NSeries.CategoryData is having unwanted text instead of cell range . and also find Expected Excel.xlsx in project directory we need same like that.It is working fine in previous versions aspose cells.I am using what i added to console appliction that version aspose cells. Please fix as early as possible. If any additional info please reply me. I tried with Aspose.Cells for .NET v19.1.x also but not working same issue.

PleaseExcelChartExport.zip (3.6 MB)

@kiranreddy0228,

Thanks for the sample project with template file.

I did evaluate your issue using your sample code a bit and found since your worksheets contain spaces so you need to do some tweak to place single quotes around worksheet name when adding charts’ series data and category data. See the updated code segment for your reference, I have tested it with your template file and it works fine:
e.g
Sample code:

......
////Set series
               
                    char excelColumnName = 'B';
                    var columnName = exportData.Tables[datatableIndex].Columns[1].ToString();

                    int columnIndex = 2;
                    if (columnName != null)
                        columnIndex = exportData.Tables[datatableIndex].Columns.IndexOf(columnName);

                    excelColumnName = (char)(excelColumnName + columnIndex);

                    string series = String.Format( "'" + reportSheetName + "'!{0}20:{0}{1}", excelColumnName,
                                                  (exportData.Tables[datatableIndex].Rows.Count + 19));
                    
                        int index = chart.NSeries.Add(series, true);
                        chart.NSeries[index].Name = columnName;


                ////Set category
                chart.NSeries.CategoryData = ("'" + reportSheetName + "'!B20:B" + (exportData.Tables[datatableIndex].Rows.Count + 19));

                chart.CategoryAxis.Title.Text = null;
                chart.ValueAxis.Title.Text = columnName;
.... 

Hope, this helps a bit.

Thanks for quick Response. your given solution resolved my problem.

Thanks,
Kiran

@kiranreddy0228,

Good to know that the suggested code figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.