Francois Goyette

RighIndent property

Posted by Francois Goyette Jun 7, 2013

Hi,

I'm using Vs2010 with CR for VS.

When I'm using LeftIndent and RightIndent property don't work when I export to PDF but when I print the report it's was ok.

I send you two file.

 

This is my command on VS for export to PDF

MonRapport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, sfd.FileName)

 

And this is my commande for printer

MonRapport.PrintToPrinter(pd.PrinterSettings, pd.PrinterSettings.DefaultPageSettings, True)

 

Francois.

 

The SAP Idea Place has been in existence for the last two or three years. Looking at the descriptions on the initial page I am not sure if it is obvious what this "thing" is all about:

 

iea place.jpg

 

I will be the first to admit I'm not the sharpest tack in the drawer, but reading the above really does not tell me how powerful SAP Idea Place is, or could be. I found a better one line description searching SCN for "SAP Idea Place":

 

Start sharing your ideas, discuss and vote for others' ideas today.

 

Hmm, OK, so what. We can share our ideas and vote for them. Cool. Now what? Well, this is where the power of SAP Idea Place comes into play;

 

Program Managers of an SAP product look at the ideas (perhaps a better term would be Enhancements). The more an idea has been voted on, the more likely it that it will be implemented. Now, looking at the ideas for this year, leaves me a little nonplused, perplexed and unimpressed. If the idea is voted up two or three times, it more than likely will not be implemented. So it is up to all of us to spread the idea around. I do it on the SCN Discussions (forums) and in my tweets (SAPCRNETSup, SAPCRDes). In this blog, I want to highlight ideas submitted in 2013 for SAP Crystal Reports and SAP Crystal Reports, developer version for Microsoft Visual Studio. I also invite you to vote on these ideas, or create your own. Spread the news, help make SAP Crystal Reports a better product. A product in your image - well in a tiny part anyhow .

 

Here is the list of ideas posted in 2013 and their stats:

 

Idea TitleDate SubmittedVotesViews
Add crdb_FileSystem.dll to Crystal Reports for Visual Studio x64 bitMay 9, 201332
SAP Crystal Report 2008 Dynamic Zoom FactorApril 29, 201325
Where do I find Crystal Reports Service Packs and Fix Packs if I don't have a support contractApril 25, 2013615
Allow physical location of subreports to be updated in master reportApril 3, 2013863
Request for ShowProgressAnimation box in CR v13 to display Summary record count similar to CR v11March 26, 2013217
Request for "SearchExpert" Button in .Net Crystal Report Viewer [13.0.5]March 21, 2013213
SAP Crystal Reports 2008/2011 missing functionality like using .xlxs data from Access/Excel/(DAO)January 29, 2013454
Ability to put OLEs in CrosstabJanuary 14, 2013221
Query LDAP via Crystal Report DesignerJanuary 4, 2013566
Add the Export Format Option "Column Width based on Objects in the Report" in the CRVS2010 for .NetDecember 19, 2012481

 

Personally, looking at the above numbers, I have to wonder how much need there is for most of the ideas. Thus, once again, I invite all of you interested in making Crystal Reports a better product to use your mouse and as the politicians would say; exercise your right to vote. Exercise your right to improve the product you are working with.

 

And in case you are wondering about the last idea being from 2012 - well, maybe I wanted to have nice round number of ideas (10), or maybe I like that idea ...

Doing a fair amount of work in a few SCN Discussion Spaces (SAP Crystal Reports, version for Visual Studio, SAP Crystal Reports, and a few others), one of my most frequent requests of those posting to Discussions / Forums is to do a bit of searching before posting a question. Doing a bit of thinking on why this appears to be as common as it is, I came to the realization that perhaps one reason is that the SCN search is quite different from the ubiquitous Google search. In this blog, I will document how I approach searching on SCN.

 

So, starting at the top - as it turns out top right hand corner - use the search box:

 

search_box.jpg

 

Now, KIS & S your search terms; Keep It  Short & Sweet. For example for a date selection formula issue with SAP Crystal Reports, it is better to use a string like ‘Crystal selection date’, than ‘date selection formula does not work for Tuesdays and Wednesdays’. Once you enter a search term, say ‘crystal formats export’ the following page will be displayed:

 

search result.jpg

 

Notice that on the left side of the page, you have a description of what type of knowledge documents were retuned (Asset Type) by the search and how many of each type of documents were found. Also, following the structure of the new SCN, you will find a list of SCN Spaces that may apply to your search term:

 

left side.jpg

Looking for a Support Note (Also known as  KBase or KBA or Knowledge Base Article), there are 356 KBAs to look at.  As I am interested in Crystal Reports and Visual Studio .NET, click on the Support Notes link. I can than select a component, in this case BI-DEV-NET:

 

resultset.jpg

 

This filters me down to 49 results – About two and a half pages.  Adding an extra search term; ‘PDF’, filters down to a manageable 20 results.

Often on the SCN Discussion Space (forum) someone may simply recommend a KBA number. See that you can also search for a specific KBA number.
If you want to go back to your original search result set, click on “Clear All Filters”:

 

clear all filters.jpg

 

Some resources may be translated and if interested, you can search for a specific language translation:

 

language.jpg

 

 

By clicking on the ’more’ link at the bottom , right side of the page, you will get additional filters that include; Region, Industry, Solution Suite, Contributor and Author:

 

more searches.jpg

You can also use date as a possible selection criteria.Sorting of results can be done on Relevance, Date and Rating:

 

date sort.jpg

For more details on searching the SCN - where we are / where we are going, see New and upcoming SCN search Enhancements as well as the blog How to use SCN search. And that is it. Following the above steps should eliminate or at least minimize waiting for a response to your query. I suspect there is nothing more irritating than a link to a KBA, a bog, wiki or what ever that comes up using the SCN search engine.

 

For more information see:

 

Everything I know about... Searching SCN

What do I need to do to get the fastest issue resolution?

SAP Community Network Rules of Engagement

Recently I have seen many of these issues being reported on the forum and support incidents as well. Almost all the possible causes have already been discussed on forums threads and knowledge base articles. This article summarizes them all.

 

Consider following scenario:

A Crystal Reports web application to view report in the web viewer, works fine from Visual Studio but when the application is deployed on IIS the reports appear blank.

Crystal Reports version could be CR 2008, CR for VS 2010 with corresponding Visual Studio version.

The first thing to do is to develop and deploy a sample application and see if it reproduces the issue.

Follow the proper deployment procedure mentioned in the Crystal Reports.NET SDK Developer guide.

A sample application eliminates the complexities of the actual application which may be an entire project.

A sample is available here: https://smpdl.sap-ag.de/~sapidp/012002523100006252712008E/csharp_web_smpl.exe

 

Possible causes and solutions to the Issue:

 

  • Compatibility Check:

Use only those versions of IIS and the browser which are supported by the respective version of Crystal Reports used.

Take a look at the Supported Platforms documentation:

http://www.sdn.sap.com/irj/boc/support?rid=/webcontent/uuid/e01d4e05-6ea5-2c10-1bb6-a8904ca76411

 

  • Upgrade Crystal Reports runtimes.

Uninstall previously installed CR runtimes, download and install the latest CR runtimes on the web server.

 

  • Do not bind the session object on the first page_load.

Instead of adding the ReportDocument directly to a http session use below workflow.

If not ispostback() 
 Dim rpt as new reportdocument()
 Rpt.Load(pathtoreport)
 Session.Add(“report”, report)
 crystalReportviewer.reportsource = rpt 
else 
 crystalReportviewer.reportsource = session(“report”) 
end if

 

 

  • Browser Settings:

Clear the browser cache, browsing history.

In case of IE 9 is used, try compatibility mode.

 

  • Dispose the ReportDocument object:

Clear the %Temp% folder. Delete all the temporary files.

Dispose the ReportDocument object after use, which also deletes the CR Temp files from the memory.

Use the following code in the unload event of the page or the code can also be written in a button press event so that the disposing is ensured manually.

boReportDocument.Close(); 
boReportDocument.Dispose(); 
GC.Collect();

 

  • External or Ajax components on the same page:

It has been observed that sometimes if we put some external components such as some third party UI controls or even Ajax controls on the same page as Crystal Reports Viewer the execution of the Ajax components interferes / conflicts with the execution of Crystal components causing the Crystal Reports viewer not to show up.

To identify if this is the cause, try putting the Ajax controls and the CR viewer on different pages. Simple way to do this is redirect to the viewer page one the controls are loaded.

This scenario could not be reproduced every time and in house and thus could not be escalated.

 

  • Use of datasets:

If Datasets are used to pass the data to the report, make sure that the datasets are being populated (after deploying the app). Many a times due to many possible reasons the data does not get populated in the dataset and thus the report shows up blank.

The best way to check is to print the dataset contents on a datagrid or a web page and see if any data is actually getting printed.

 

  • Use of 64 bit applications / tools to deploy the application and associated data connections:

Many customers don’t follow the conventional ways to deploy the web or win apps.

Instead, different tools are used like TFS, Publishing tools, Package builders etc. Few of them are available in both flavours i.e. 32 bit and 64 bit.

If the Crystal Reports .NET application is 32 bit it requires 32 bit database providers / drivers. If the third party publisher is 64 bit, while deploying the app it configures everything as 64 bit which breaks the app on the server. In case of ODBC make sure that the DSN is 32 bit for 32 bit apps.

 

  • Possible errors:

When browser displays a blank page, check the left bottom corner of the browser; see if a yellow triangle is displayed, double clicking it displays the error.

 

“Bobj is undefined”

This simply means that the application is not able to find / access the CR Viewer files.

 

“Server Error /”

This mainly gets caused by IIS settings, check the IIS console for additional settings of the application Virtual directory or the application pool.

 

Use the top right corner search box to get more info on above errors, there is a lot of documentation available.

To get started, see this:

Getting started and moving ahead with Crystal Reports .NET applications.

On September 12, Microsoft launched Microsoft Visual Studio 2012. We’ve received a lot of interest already, so here are some details on how we will support this product.

 

Our development teams are hard at work updating SAP Crystal Reports to support Visual Studio 2012 and .NET Framework 4.5, with plans to make this update available in late Q1 2013. Dates are of course subject to change, based on product readiness.

 

You should note that support for Microsoft Visual Studio 2012 will be delivered in an upcoming service pack release, which can be applied to an installation of the current product (SAP Crystal Reports, version for Visual Studio 2010).

 

To reflect support of this 2012 release, we will be renaming our product to SAP Crystal Reports, developer version for Microsoft Visual Studio. We are dropping the year from our naming convention, since the product will support multiple releases of VS. This allows us to update our offering more quickly as well as maintain fewer versions of the product. In turn, that should also make it less confusing for users to decide which version is needed.

 

In addition to supporting Microsoft Visual Studio 2012, the new release of SAP Crystal Reports will also add support for Windows 8. I'll update this post closer to our release with specifics around platform support updates.

The very important and frequently used features in the Crystal Designer are the ReportOptions.

Consider a scenario where you would need to access / modify the values of Report Options of a Crystal report at runtime in a Crystal Reports .NET application.

In this case we would need to use the Inproc RAS APIs of Crystal Reports.

 

 

‘Report Options’ could be found at below places in the Crystal Designer.

Crystal Reports 2008 – “FILE --> Report Options”

CR08 RO J.JPG

 

Crystal Reports for Visual Studio 2010 – “Crystal Reports --> Report --> Report Options. “

CRforVS2010 RO J.JPG

 

Not all but few of these values are accessible using InProc RAS .NET APIs.

 

Here is how…

Take a look at the “ ReportOptions Class provided by CrystalDecisions.ReportAppServer.ReportDefModel Namespace” in the API reference Guide for InProc RAS .NET SDK.

 

Crystal Reports 2008 InProc RAS .NET SDK API reference guide.

Crystal Reports for Visual Studio 2010 InProc RAS .NET SDK API reference guide

 

Here is the sample code to demonstrate the use of these APIs.

 

CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        ISCDReportClientDocument rcd = new ReportClientDocumentClass();
        rd.Load(Server.MapPath("ReportOptionsSampleReport.rpt"));
        rcd = rd.ReportClientDocument;
        CrystalDecisions.ReportAppServer.ReportDefModel.ReportOptions OReportOptions = rcd.ReportOptions;

        OReportOptions.CanSelectDistinctRecords = true;
        OReportOptions.ConvertNullFieldToDefault = true;
        OReportOptions.ConvertOtherNullsToDefault = true;
        OReportOptions.EnableAsyncQuery = false;
        OReportOptions.EnablePushDownGroupBy = true;
        OReportOptions.EnableSaveDataWithReport = true;
        OReportOptions.EnableSelectDistinctRecords = true;
        OReportOptions.ErrorOnMaxNumOfRecords = true;
        OReportOptions.RefreshCEProperties = true;
       rcd.SaveAs("NewCrystalReport.rpt", @"C:\");

 

 

These APIs could be really usefull specially while plaiyng with the report object on the fly and edit / modify the report options of the target rpt file.

The error message “Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack” is very generic and can be caused by many different factors.

Here is some useful information regarding the possible causes and possible solutions to this issue.

 

 

Background:

Consider a windows / web application developed either with VS 2008 and CR 2008 or VS 2010 and CR for VS 2010. (Mainly, any compatible combination of VS and CR).

This issue mainly occurs after the application is deployed; same solution applies to the development environment too.

 

 

Possible causes and Resolutions:

The only cause to this issue is that “The application could not find the crystal report (.rpt )” be whatever the reason.

 

 

Here are the possible reasons for this error message.

 

  • The report location specified in the ‘Load ()’ method is invalid or report does not exist at that location. :

This happens because while developing the application, report location is specified from the dev machine but once the application is deployed, the location changes with respect to IIS folder structure.

 

 

  • Reports are not intact :

If the Reports are published using visual studio ‘Publish’ option but if not published properly there is a possibility that the reports may loose content or get corrupted. The best way to check this is too compare the report sizes from the Dev and Prod / client machine.

 

 

  • Random change of permissions or Security / Access policy:

This is a possible cause when some times the report works but sometimes it throws the error. You may want to check the Security policy applied to your machine/ domain if the rights for your application over the report location are variable / changing.

Use Process Monitor and look for any access denied errors or permission issues.

 

 

  • All the possible causes to the ‘Load report failed’ error message also apply to this issue as well. Here’s the best article written by Ludek which covers them all.

Troubleshooting the Load Report Failed Error

 

 

  • The other strong cause to this issue is the print job limit of the Crystal print engine getting exceeded. Consider a scenario where the application performs multiple view / export / print functions on reports, reports work fine most of the times but intermittently throw this exception. Below is the document you might want to take a look at to resolve this issue.

Crystal Reports Maximum Report Processing Jobs Limit

 

 

And finally, to avoid many such common issues here are some recommendations by SAP.

Improving Crystal Reports Performance in Visual Studio .NET Applications

 

 

 

I will be updating this document if I come across more such causes to this issue.

This article gives an idea as how to use Crystal report in .Net Windows Application with parametrized queries andOracle as Database using dataset.I had searched on internet for articles related to Crystal Report with parametrized query with Oracle,but I was unable to find any good article on this topic.So I am posting my article on this topic.

 

There are three main points in this article.
1. Crystal Report with parametrized query.
2. Using Oracle Views because here stored procedure will not be able to do this job because of the fact that OracleStored Procedure does not return Multiple Rows(Record Set) as Sql Server Stored Procedures do.
3. Using DataSet.
Hence I have used Oracle views in this project to bind the Crystal Report and Dataset.Then I wrote my parametrized query on the view as we do generally on database tables. So this Project will give a good idea on how to Use CrystalReport with Oracle. There are many methods to do this job, even we can create Oracle packeges which will return mutiple records as SQl Server Stored Procedures. But I found this way simple and fast to do.

 

Note: No special background knowledge is needed for this article. Any beginner or Intermediate will be able to understand this code.It will be good if you have a basic knowledge of database views

 

You can also follow this link for the same:

http://www.codeproject.com/Articles/28330/Using-Crystal-Report-with-Oracle-and-parametrized

 

Hope you will found this blog useful .

 

- Bwuser

Sometimes we just want to know the database that is being used by Crystal Reports and its properties. It’s tedious to go back to designer and check every report in it. How would it be if we do that using .NET SDK?

 

We are familiar with the ReporDocument Object Model, but to achieve this we have to leverage the ReportClientDocument Object Model. These two models can be used interchangeably to manipulate a report.

 

If we are to find the properties from the designer then:

  1. Open the report.
  2. Go to Database> Set DataSource Loaction
  3. Choose Current Data Source > Database.
  4. Expand the properties of the Database as well as the Table

db.JPG

As far as this task is concerned we have to use to inProc RAS where inProc stands for In-Process and it means that the deployment package for the RAS .NET application requires only the .NET assemblies. Does definition look complicated? Here is the simpler version. inProc RAS has the ability to create/ manipulate the report definition/template without requiring any enterprise products like BOE, Crystal Server etc….

 

The references that you would require for creating the .NET project are following:

  1. CrystalDecisions.CrystalReports.Engine
  2. CrystalDecisions.ReportAppServer.ClientDoc
  3. CrystalDecisions.ReportAppServer.Controllers
  4. CrystalDecisions.ReportAppServer.DataDefModel

 

Following code can help you achieve the objective:

 

 

Sample Code

        ReportDocument rd = new ReportDocument();

        rd.Load(Server.MapPath("CrystalReports.rpt"));

        ISCDReportClientDocument rcd = rd.ReportClientDocument;

        DatabaseController databaseController = rcd.DatabaseController;

        CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo connectionInfo = databaseController.FindConnectionInfoByDBServerName("DatabaseName");

        PropertyBag oldPb = connectionInfo.Attributes;

        foreach (String attribute in oldPb.PropertyIDs)

        {

            if (oldPb[attribute].ToString().Equals("System.__ComObject"))

            {

               Response.Write(attribute + " (" + oldPb[attribute].GetType().ToString() + ") = ");

               PropertyBag oldLogonPb = (PropertyBag)oldPb[attribute];

               foreach (String logonAttribute in oldLogonPb.PropertyIDs)

               {

                   Response.Write(logonAttribute + " = " + oldLogonPb[logonAttribute].ToString() + " (" + oldLogonPb[logonAttribute].GetType().ToString() + ")");

               }

            }

            else

            {

                Response.Write(attribute + " = " + oldPb[attribute].ToString() + " (" + oldPb[attribute].GetType().ToString() + ")");

            }

        }

        CrystalDecisions.ReportAppServer.DataDefModel.Tables tables = databaseController.Database.Tables;

        CrystalDecisions.ReportAppServer.DataDefModel.Table customerTable = (CrystalDecisions.ReportAppServer.DataDefModel.Table)tables.FindTableByAlias("Sales_by_Category");

        Response.Write("Owner" + " = " + customerTable.QualifiedName + " ");

 

 

 

This code works for Crystal Reports 2008 (12.x) and Crystal Reports for Visual Studio 2010 (13.x) without any problem.

 

Additional Reference:

  1. Crystal Reports .NET SDK API Reference
  2. Report Application Server Database Connectivity

Normally we work on Section Expert to manipulate the properties of the Area or the Section underlying it. How would it be if the same can be done using .NET SDK?


I would admit that it would be bit difficult, because it involves finding many things starting from Area Name. If you want to override the design settings at runtime then go for it. It can make things simple if used properly. If you are looking forward to update some of the properties of few Areas, then it’s a situation where this code will be useful.


For setting properties for all Areas in a report following code can be used


 

Sample Code

        ReportDocument reportDocument= new ReportDocument();

        reportDocument.Load(Server.MapPath("CrystalReports.rpt"));

        ReportDefinition myReportDefinition = reportDocument.ReportDefinition;

        Areas areas = myReportDefinition.Areas;

 

        for (int i=0; i < areas.Count; i++)

        {

          Area area = areas[i];

          if (area.Name == areaName)

          {

            AreaFormat areaFormat = area.AreaFormat;

            areaFormat.EnableHideForDrillDown = true;

            areaFormat.EnableKeepTogether = true;

            areaFormat.EnableNewPageAfter = true;

            areaFormat.EnablePrintAtBottomOfPage = true;

            areaFormat.EnableResetPageNumberAfter = true;

            areaFormat.EnableSuppress = true;

 

          }

        }

 

 

The code can be tweaked a little for setting these properties for a specific area. If you have no idea on how to find the areas and don’t want to go to designer, this could be helpful.

 

As far as advantages are concerned you can:

  1. Set hide for drill down.
  2. Keep area together.
  3. Set the new page after.
  4. Set the new page before
  5. Set the print at bottom of page
  6. Set the reset page number after
  7. Set the area visibility

Internet Explorer is the preferred browser on Windows OS as it comes by default and always is a default browser on machine, unless you change it. When you open a web page in it, it may show everything correctly, but sometimes it fails. I have seen many occurrences of its failure when working with Crystal Reports. Have we ever given a thought why it fails, why it does not show Crystal reports correctly?

 

 

 

 

 

To start with let’s define failure.

 

While using Internet Explorer 9, some web pages might not display at all, portions of a webpage might be missing, information in a table might be in the wrong locations or colors and text might be incorrect, crystal report toolbar is not displayed, data is not shown by crystal report.

 

The definition of failure is really not precise, but should be good enough to understand what can happen.  IE 9 is not supported at this time by Crystal Reports any version. With this blog some of the information that I have gathered can shed light on the “Why it is not supported?”

 

 

 

Why this happens?

 

We being developers always want to ensure that the website should be compatible with every browser and every established web standard. We like to see our websites to run on new browsers, browsers does respect it and tries to display to page/ website to most compliant modern web standard.

 

 

 

Most of the browsers recommend using HTML 5, latest in the HTML league, supporting the widest variety of established and emerging standards, as well as the broadest range of web browsers. There are no specific reasons for this behavior; every browser suggests incorporating features from the latest standards in the website.  I don’t intend to share all information when there are good articles available. Probably some of you must have gone through it as well.

 

 

 

While going through most of the articles, I read something about DOM and Chakra. The new document object model (DOM) loads the application and web pages faster. Chakra is the new JavaScript engine, which takes the advantages of multiple CPU cores through Windows to interpret, compile and run code in parallel.

 

 

 

Hitting arrow in the dark:

 

Crystal Reports Viewer depends heavily upon the JavaScript. When we run the web page (report), the new Jscript engine is not able to interpret the things properly resulting in the failure or it could be the new DOM not able to process the document and incorporate back the processed information into the presented page or both.

 

 

 

What is to be done now?

 

Use the X-UA-Compatible header to specify the versions of Internet Explorer that your pages should support. Use document.documentMode to determine the compatibility mode of a webpage. Compatibility View can also be turned on. Last option would be to wait for new release of Crystal Reports patch, but it is likely to support in the Compatibility View.

 

 

 

SAP must revive its strategy to incorporate all the features of HTML5 for Crystal Reports Viewer and the day shouldn't be far when we would be seeing it in the forthcoming patches.

 

Additional Resources:

  1. HTML5
  2. Document Object Model (DOM)
  3. Introducing Compatibility View
  4. Defining Document Compatibility
  5. Why are some webpages blank or incorrectly displayed in Internet Explorer 9?
  6. Internet Explorer 9 FAQ for IT Professionals

In the last How to find the ReportObjects in Crystal Report using Crystal Reports .NET SDK? I discussed about ReportObject and various objects that inherits some of the properties of ReportObject with this blog I would like to highlight some the things that can be done to TextObject, in order words let’s see what all properties can be explored and used in the project.

 

 

TextObject represents a text object found in a report. The namespace that contains it is CrystalDecisions.CrystalReports.Engine.

 

Crystal Report’s Designer offers extensive properties than what SDK offers, but these properties can be used to add borders, change fonts and some of the common properties seen in Format Editor. So let’s start with the first code changing font and adding border around the object:

 

 

Sample Code for Customizing the TextObject

private void ChangeTextObjectsPropeties()

    {

        ReportDocument rd = new ReportDocument();

        TextObject txtObj;

        rd.Load(Server.MapPath("CrystalReports.rpt"));

        Font fp = new Font("Tahoma", 10);

       

 

 

        txtObj = (TextObject)(rd.ReportDefinition.ReportObjects["Text2"]);

 

 

        if (txtObj != null)

        {

            txtObj.ApplyFont(fp);

            Border bdtxt = txtObj.Border;

            bdtxt.BorderColor = Color.Red;

            bdtxt.BottomLineStyle = LineStyle.DotLine;

        }

        CrystalReportViewer1.ReportSource = rd;

 

    }

 

 

Next code is dealing with some of the common properties of Format Editor:

 

Sample Code Changing the Common Properties of TextObject

private void ChangeTextObjectsPropeties2()

    {

        ReportDocument rptDoc = new ReportDocument();

        rptDoc.Load(Server.MapPath("rystalReports.rpt"));

        TextObject txtObj;

        txtObj = (TextObject)(rd.ReportDefinition.ReportObjects["Text2"]);

        if (txtObj != null)

        {

            txtObj.ObjectFormat.EnableCanGrow = true;

            txtObj.ObjectFormat.EnableKeepTogether = true;

            txtObj.ObjectFormat.HorizontalAlignment = Alignment.LeftAlign;         

           

        }

    }

 

There are more properties which can be used when ObjectFormat is used, like:

 

  • ObjectFormat.CssClass
  • ObjectFormat.EnableCloseAtPageBreak
  • ObjectFormat.EnableSuppress

 

How come I miss the properties it inherits from ReportObject, these are some the those which can be used to get or set the height, width, upper top or left position etc…

 

 

 

We can manipulate some of the properties using the code given above. I don’t want to miss the point here that it’s all ReportDocument Object Crystal Reports .NET Applications and Object Models used which comes in the picture while doing the stuff mentioned above.

 

I see many advantages here and some of them are:

 

  • Ability to change the font and it colors.
  • Ability to highlight the TextObject using borders around it.
  • To enable the can grow option for the specific TextObject or all.
  • To set Horizontal Alignment.

    

 

Though these properties are not really extensive but are powerful enough to help you personalize your application at runtime.

 

Additional Reference:

Crystal Reports .NET SDK API References

Once I wanted to find a field of a Crystal Report and manipulate its property. When I learnt about ReportObject things become simpler as it helped me find all of them. Let’s learn a little about it.

 

What is ReportObject?

ReportObject could be a database field, text labels, cross-tab, binary large objects, horizontal or vertical lines etc.. For e.g. TextObject, BoxObject, CrossTab Object etc...

 

For SDK it is a base class providing generic properties for various kinds of report objects. To use this with our project we need to include CrystalDecisions.CrystalReports.Engine Namespace.

 

The CrystalDecisions.CrystalReports.Engine namespace provides support for the ReportDocument object model, so I would say that it is available only when we use ReportDocument object model (For more on Object Models, see Crystal Reports .NET Applications and Object Models used).

 

ReportObject has two members Count and Item. Object of the report can be retrieved either by name or its index through Item. Rather than retrieving any specific object I am retrieving all the objects of a report and subreport(s) as well.

 

You can modify the code to suit your needs. Following code helps you find the ReportObjects in main report.

 

Sample Code for Finding Objects in Main Report

private void FindObjectsinMainReport()

    {

        ReportDocument reportDocument = new ReportDocument();

        string reportPath = Server.MapPath("CrystalReports.rpt");

        reportDocument.Load(reportPath);

        if (reportDocument.ReportDefinition.ReportObjects.Count > 0)

        {

            Response.Write("</br>");

            Response.Write("<table border=1 cellspacing=2>");

            Response.Write("<tr>");

            Response.Write("<td><b>Report Object Name</b></td>");

            Response.Write("<td><b>Report Kind</b></td>");

            Response.Write("<td><b>Report Object Format</b></td>");

            Response.Write("</tr>");

 

 

            foreach (ReportObject reportObject in reportDocument.ReportDefinition.ReportObjects)

            {

                Response.Write("<tr>");

                Response.Write("<td>" + reportObject.Name + " </td>");

                Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");

                Response.Write("<td>" + reportObject.ObjectFormat.ToString() + " </td>");

                Response.Write("</tr>");

 

 

            }

            Response.Write("</table>");

        }       

    }

 

 

For finding ReportObjects in Subreport(s) use following:

 

Sample Code for Finding Objects in Subreports

private void FindObjectsinSubReports()

    {

        ReportDocument reportDocument = new ReportDocument();

        string reportPath = Server.MapPath("CrystalReports.rpt");

        reportDocument.Load(reportPath);

        if (reportDocument.Subreports.Count > 0)

        {

            foreach (ReportDocument rdoc in reportDocument.Subreports)

            {

 

 

                if (rdoc.ReportDefinition.ReportObjects.Count > 0)

                {

                    Response.Write("</br>");

                    Response.Write("<table border=1 cellspacing=2>");

                    Response.Write("<tr>");

                    Response.Write("<td><b>Report Object Name</b></td>");

                    Response.Write("<td><b>Report Kind</b></td>");

                    Response.Write("<td><b>Report Object Format</b></td>");

                    Response.Write("</tr>");

 

 

                    foreach (ReportObject reportObject in rdoc.ReportDefinition.ReportObjects)

                    {

                        Response.Write("<tr>");

                        Response.Write("<td>" + reportObject.Name + " </td>");

                        Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");

                        Response.Write("<td>" + reportObject.ObjectFormat.ToString() + " </td>");

                        Response.Write("</tr>");

 

 

                    }

                    Response.Write("</table>");

                }

            }

        }

 

 

Most of the objects inherit the properties of ReportObject, some of them inherit all and some few. Here's the table listing all of them:

 

BlobFieldObject ChartObject Properties CrossTabObject
FlashObject Properties GraphicObject MapObject
OlapGridObject PictureObject BoxObject
DrawingObject FieldHeadingObject FieldObject
LineObject SubReportObject TextObject

 

I started writing this blog last year and completing it now, didn't notice that calendar on the wall has changed, though I am late, but Happy New Year SCN.

 

Note: I have published the blog long time back, with the new Jive platform I have edited some of the stuff to make few things prominent in the blog

Service Pack 2 for Crystal Reports for Visual Studio 2010 (CRVS2010) was released on November 23, 2011. For downloads details see the sticky forum thread SP 2 for SP 2 for Crystal Reports for Visual Studio 2010 released! This blog is a partial listings of issue resolved in the Service Pack. At this time, 16 resolved issues remain undocumented, but will be added to this blog in January of 20112.

List of Published KBases

1566763 - CRVS2010 WPF Viewer error; "System.NullReferenceException was unhandled" PageControl.OnMouseMove
1540637 - Error: External component has thrown an exception. Launching the Database Expert in the embedded Crystal Reports designer in Visual Studio
1544675 - Error; 'Object reference not set to an instance of an object' when using the CR WPF viewer in VS2010
1578823 - CRVS2010; "Load Report Failed" error when Report is open in any full version of the CR Designer
1638191 - Using RTL language (Arabic) the CR viewer Group Tree Panel does not display RTL
1631283 - Error; 'Failed to load database information' when reporting off of file system data
1553469 - How to enable Database logging in Crystal Reports for Visual Studio 2010

1299185 - Error: Operation not yet implemented or Failed to Export, when exporting a Crystal Reports to Text format
1451960 - Null or empty values are not surrounded with delimiter when exported to CSV format
1659185 - The special Crystal Reports field, 'File Name and Path' shows temp path and temp name when viewing a report
1452648 - Dynamic Cascading Parameter prompts two times when using the Crystal Reports in VS .NET
1580338 - When refreshing a report that contains a linked subreport report takes long time to execute
1659111 - GCHandle left in memory for each open and close of a Crystal Report in VS2010 application
1356672 - Crystal Reports special field "File Path and Name" displays incorrect information in a Visual Studio .NET application
1593658 - Impersonation of database Log On credentials failure in report generation when set at runtime in a .NET application
1661239 - Summary fields are converted to String fields
1661276 - Using the Crystal Reports SetTableLocation method in VS .NET causes long report processing delays
1661200 - Not able to copy text from report objects using the Crystal Reports WinForm viewer for VS .NET
1631722 - Date function in a Selection Formula is removed when running a report in a VS .NET application

1525822 - Exception "Object reference not set to an instance of an object." thrown when clicking on Parameter Panel button in Crystal Report .NET Windows Form Viewer
1603082 - Cross-tab background colors not retained when exporting a report to PDF format
1603154 - Shared variable display the incorrect value in Crystal Reports
1427747 - Why does a CR .NET SDK web app have problems running on IIS 7 in integrated pipeline mode?
1545536 - Alignment set to Justify causes broken underline

List of Issues Database ADAPT Numbers to be Documented:

ADAPT01556096
ADAPT01556327
ADAPT01576541
ADAPT01580233
ADAPT01587508
ADAPT01522436
ADAPT01511671
ADAPT01532776
ADAPT01488970
ADAPT01509018
ADAPT01554382
ADAPT01561576
ADAPT01493545
ADAPT01493590
ADAPT01551066
ADAPT01581445

 

**** For a final compilation of fixed issues see the Wiki Crystal Reports for Visual Studio 2010 - Service Pack 2 - Fixed Issues

While designing the report we drop the required objects within the canvas/ layout of the report. Have we ever tried thought what is the proper name of it? How that can be found using .NET SDK?


Not many people who design the reports actually know that Crystal Reports has 5 prominent Areas - Report Header, Page Header, Details, Report Footer, and Page Footer. Group Header and Group Footer are added later only if group, summary, or subtotal is added to the report, which takes the count to 7.

 

When a group, summary, or subtotal is added, the Group Header area appears directly above the Details area and the Group Footer area appears directly below the Details area. (See the Output below)

The following is the code that has helped me find Areas in a Report, which has a sub-report, summary, subtotal and group etc…

 

Sample Code to Find Areas

private void FindAreas()

    {

        ReportDocument rd = new ReportDocument();

        string reportPath = Server.MapPath("CrystalReports.rpt");

        rd.Load(reportPath);

        ReportDefinition reportDefinition = rd.ReportDefinition;

        Areas areas = reportDefinition.Areas;

 

 

        if (areas.Count > 0)

        {

 

 

            Response.Write("</br>");

            Response.Write("</br>");

            Response.Write("<table border=1 cellspacing=2>");

            Response.Write("<tr>");

            Response.Write("<td><b>Area Format</b></td>");

            Response.Write("<td><b>Area Kind</b></td>");

            Response.Write("<td><b>Area Name</b></td>");

            Response.Write("<td><b>Section Name</b></td>");

            Response.Write("</tr>");

 

 

            foreach (Area area in areas)

            {

                Response.Write("<tr>");

                Response.Write("<td>" + area.AreaFormat.ToString() + " </td>");

                Response.Write("<td>" + area.Kind.ToString() + " </td>");

                Response.Write("<td>" + area.Name + " </td>");

                Response.Write("<td>" + area.Sections.ToString() + " </td>");

                Response.Write("</tr>");

            }

 

 

            Response.Write("</table>");

        }

 

 

    }

 

The output of the code is as follows:

Area.PNG

My quest was to find the Areas using Crystal Reports .NET and the code has helped me achieve the same.

Filter Blog

By author: By date:
By tag: