Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am in need to change the chart's data title and group title in during for localisation purpose. I am using below code to loop through the reports object and get the chart object
C#
foreach (CrystalDecisions.CrystalReports.Engine.Section section in rpt.ReportDefinition.Sections)
            {
                CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument clientDocument =
               rpt.ReportClientDocument;
                CrystalDecisions.ReportAppServer.ReportDefModel.ReportObjects myCharts;
                myCharts = clientDocument.ReportDefController.ReportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindChart);
                foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject oldObject in myCharts)
                {
                    if (oldObject.Kind == CrReportObjectKindEnum.crReportObjectKindChart)
                    {
                        CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject oldChart;
                        CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject newChart;
                        oldChart = (CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject)oldObject;
                        newChart = (CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject)oldChart.Clone(true);
                        if (!string.IsNullOrEmpty(oldChart.ChartStyle.TextOptions.DataTitle))
                        {
                            langtran1 = oldChart.ChartStyle.TextOptions.DataTitle.Replace(" ", "");
                            langtran1 = langtran + langtran1;
                            langtran1 = Regex.Replace(langtran1, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);
                            langtran1 = langtran1.Replace(".", "");
                            oldChart.ChartStyle.TextOptions.DataTitle = GetEnumvalues(langtran1);
                            langtran1 = "";
                            clientDocument.ReportDefController.ModifyChartObject(oldChart, oldChart);
                            clientDocument.RefreshReportDocument();
                        }                    
                    }
                }
            }

For the below line
C#
clientDocument.ReportDefController.ModifyChartObject(oldChart, oldChart);
                            clientDocument.RefreshReportDocument();


i am getting exception - The chart data is not valid.

This exception is arising only for the reports having chart type CrystalDecisions.ReportAppServer.ReportDefModel.CrChartTypeEnum.crChartTypeCrossTab

Please help me what i have to do for this to work.

Sivaraman.
Posted
Updated 5-Nov-14 1:40am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900