Print Page | Close Window

Getting the chart titles with C#

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9120
Printed Date: 02 May 2024 at 10:01pm


Topic: Getting the chart titles with C#
Posted By: AlexanderF
Subject: Getting the chart titles with C#
Date Posted: 16 Feb 2010 at 3:03am
Hello!

I have some reports which should be prepared for multilingual support. While searching the different solution paths, I found the following code line:

((TextObject)ReportDocument.ReportDefinition.Sections["YourSection"].ReportObjects["YourField"]).Text = myResourceText

I created a function which reads out the elements of a given report and writes the name and the text of the element into a resx file. If the report object is not a TextObject and no FieldHeading, the name and the type of the object are written into the resx file.

private void LoadReportLanguageResources(ReportDocument report, string resourceFilePath)
{
   ResXResourceWriter resXWriter = new ResXResourceWriter(resourceFilePath);
   //set the language values of the report - find all fields and sections

   foreach (ReportObject reportObject in report.ReportDefinition.ReportObjects)
   {
       if ( reportObject.Kind == ReportObjectKind.TextObject ||
            reportObject.Kind == ReportObjectKind.FieldHeadingObject)
      {
         resXWriter.AddResource(reportObject.Name, ((TextObject)reportObject).Text);
      }
      else
      {
         resXWriter.AddResource(reportObject.Name, reportObject.ToString());
      }
   }

   resXWriter.Close();
   resXWriter.Dispose();
}

I have the following objects included in the report:
Engine.BoxObject
Engine.ChartObject
Engine.CrossTabObject
Engine.FieldObject
Engine.PictureObject

As my Charts contain titles and legends, I need to translate the content of those elements. Does anybody know how I could access those values via C#?

Thank you for your advice.
Alex



Print Page | Close Window