Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Designing reports on the fly Post Reply Post New Topic
Author Message

Joined: 08 Jan 2010
Online Status: Offline
Posts: 3
Quote laoujin Replybullet Topic: Designing reports on the fly
    Posted: 08 Jan 2010 at 6:59am

I've asked this a few people already in my organisation and while they have been working with Crystal Reports for a while no one could give me a definitive answer. Google was also quite vague on this.

What I'm trying to do is build an entire report (rpt file) in .NET code (preferable .NET but if that's not possible any code will do really)
The reason I want to do it in code is because Crystal Reports is a pain to align stuff and nearly impossible to do simple copy+paste operations (all our reports have pretty much the same header and/or footer, we want all 'titles' and boxes to be aligned exactly the same, everywhere the same spacing etc etc)

So what I want to do is:
Create a new RPT file or open an existing one and then:
- Adding lines & labels.
- Changing properties such as location, size, font, text, format, alignment, ... the works.
- Adding conditional code to bound fields.
- Adding sections and changing section properties.
- etc etc

Additionally it would be nice if there were some sort of DOM so the entire report can be read in code aswell.

Now this site says on the CR.NET overview page:
"Sample code shows you how to program the RDC and the RAS."

I guess this means that it is indeed possible to create a report in .NET code? And that this book details how exactly it is done?

Edited by laoujin - 08 Jan 2010 at 7:01am
IP IP Logged

Joined: 16 Feb 2010
Location: Austria
Online Status: Offline
Posts: 2
Quote AlexanderF Replybullet Posted: 16 Feb 2010 at 2:45am
I had the same problem and solved this issue with creating templates for a landscape and portrait orientation.

In the templates I included the header and footer lines with the logos and additional text (parameter field for the report title)
When the layout for the header and footer was finished, I locked the fields and saved the template.

When I create a new report, I select my template in one of the wizard screens.
The first page, headers and footers were everywhere the same while I had the possibility to add additional sections, code parameters ...

IP IP Logged

Joined: 25 Mar 2010
Online Status: Offline
Posts: 6
Quote Isak Replybullet Posted: 17 Dec 2010 at 12:00pm
You can't create new report objects dynamically with the free version, but I have been told it is possible with the paid one.
IP IP Logged
Senior Member
Senior Member

Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 12 Apr 2011 at 6:29am
Yes, you can have users control, which should include adding objects dynamically. To me, its very fussy, you have to deal with the various section and use the correct objects. You then can control positions, etc. You need a way to collect those parameters for the objects your are trying to add, so the application needs a strong interface for the user.
You can get a suprisiing amount of control, but you also really need to have the design you want locked down before you begin.   The various objects are set in the individual section of the report as  collections. As I recall there are field objects, text objects, and report objects. I am probably missinig a bunch butyo get the idea. You would have to create a new object of the correct type for the collection, set the properties you want, load data into it if a field objects, postion it which I believe is limited to top and left settings.
So yes it can probably be done, but will it do what you want in the way you want I cannot answer.
All I can say is from my perspective this is not for the faint of heart and should really meet a need. There are other more reasonable solutions such as templates that will cover most requirements.
Let us know how you turn out.
John W.
IP IP Logged

Joined: 18 Dec 2011
Location: United States
Online Status: Offline
Posts: 1
Quote aldis Replybullet Posted: 18 Dec 2011 at 5:53pm
I have also put up a question about 'Passing values to parameters used by a SP which is a datasource for a subreport'.
NOBODY has replied to it. Will you kindly have a look at it and help me?
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

This page was generated in 0.031 seconds.