Skip to Content
Former Member
Apr 05, 2012 at 04:12 PM

how i can get the number of column and the DataFields in a table (CrossTable) from a report file (.rpt) with code C#



I could open and load the report (.rpt) , i got the CrossTableObject , i could write it's name in Console but i cant get the number of column and table's DataFields ... plzzz help me... and thanx
(I use MS Visual 2010, Crystal Reports 2011, SAP BusinessObjects Enterprise XI 4.0)

ReportDocument rpt = new ReportDocument();            rpt.Load("test.rpt");ISCDReportClientDocument rptClientDoc = rpt.ReportClientDocument;                        foreach (Area area in rptClientDoc.ReportDefinition.Areas)             {                 Console.WriteLine("--+"+area.Name);                 foreach (Section section in area.Sections)                 {                     Console.WriteLine("----+"+section.Name);                     foreach (ReportObject obj in section.ReportObjects)                     {                         Console.WriteLine("------+" + obj.Name + "::" + obj.ClassName+"::"+obj.Kind);                         switch (obj.ClassName)                         {                             case "CrystalReports.ChartObject":                                 ChartObject boChartObject = (ChartObject)obj;                                 foreach (CrystalDecisions.ReportAppServer.DataDefModel.Field field in boChartObject.ChartDefinition.DataFields)                                 {                                     Console.WriteLine("--------+"+field.Name+"::"+field.Type);                                 }                                 foreach (CrystalDecisions.ReportAppServer.DataDefModel.Field field in boChartObject.ChartDefinition.ConditionFields)                                 {                                     Console.WriteLine("--------+" + field.Name+"::"+field.Type);                                 }                                 break;                             case "CrystalReports.CrossTabObject":                                 CrossTabObject tab = (CrossTabObject)obj;                                 Console.WriteLine("--------+" + tab.Name);                                   //here i want get the number of column and DataFields