Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2004, 02:00 PM
Authorized User
 
Join Date: Oct 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default CrystalReportViewer1.PrintReport

I'm trying to set up a print button on the report viewer screen. The code in the book (CR for VS.Net, 2nd Edition) indicates that

CrystalReportViewer1.PrintReport

... should present a print dialog box, which would be perfect. However, when I type in the code, I receive a notice that "Print
Report is not a member of CrystalDecisions.Web.CrystalReportViewer". I've worked at setting up various references to see if I just didn't have references set up properly, but that's not where my problem seems to be. I really want to get this working, because there are a host of other members, according to the book, that I want to include in this project.


 
Old November 6th, 2004, 03:02 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The topics that we have covered here are :

1) Introduction

2) Getting a feel of it - Using an existing Crystal Report file in your .aspx page

3) Crystal Reports Walkthrough - using the Pull Model

4) Crystal Reports Walkthrough - using the Push Model

5) Exporting the Report file into other formats



INTRODUCTION


Crystal Report comes in various flavors and the one that is required for building reports for .NET is "". It exposes a rich programming model with which we could manipulate its properties and methods during runtime. If you are developing your .NET applications using Visual Studio .NET then you won’t have to install any additional software as it is already built into Visual Studio .NET.



---- Advantages -----

Some of the major advantages of using are :

- Rapid report development

- Can extend it to complicated reports with interactive charts

- Exposes a report object model using which it can interact with other controls on the web form

- Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf

Â

---- The Architecture ----

The various components that make up a simple implementation of Crystal Report as a 2-tier architecture, required for web applications are

The Client :

The client only needs a browser to access the reports which are embedded into the .aspx pages.

The Web Server hosts the :

- Crystal Report Engine (CREngine.dll)

Along with other tasks like merging the data with the report file, exporting reports into different formats, etc., it is the Report Engine that converts your Crystal Report into plain HTML that is passed on to your .aspx page.

- Crystal Report Designer (CRDesigner.dll)

The reports are created from scratch using the Crystal Report Designer, with which you could design the titles, insert data, formulas, charts, sub-reports, etc.

- The .rpt Report file

The first step to implement a report into your web application would be to create it using the Crystal Report Designer interface. You will find some ready-made .rpt samples provided with the default installation.

- The Data Source

The way your .rpt file gets the data depends on which method you choose. You can choose to make Crystal Report itself to fetch your data without writing any code for it or you can choose to manually populate a dataset and pass it on to the report file. We will look at the various possibilities a little later in this article.

- Crystal Report Viewer web form Control (CRWebFormViewer.dll)

The Crystal Report Viewer control is a web form control that can be inserted into your .aspx page. It can be thought of as a container that hosts the report on the .aspx page.Â



Note : In a more complex implementation, the reporting server and the web server could be on different physical servers, where the web server would make an HTTP request to the reporting server. The Crystal Reports could also be implemented as a web service.



---- Implementation Models -----

Fetching the data for the Crystal Report could be done by using any of the following methods :

- Pull Model :

where in Crystal Report handles the connection to the database using the specified driver and populates the report with the data, when requested.

- Push Model :

where it is the developer who has to write code to handle the connection and populate the dataset, and pass it on to the report. The performance can be optimized in this manner by using connection sharing and manually limiting the number of records that are passed on to the report.



---- Report Types ----

Crystal Report Designer can load reports that are included into the project as well as those that are independent of the project.

- Strongly-typed Report :

When you add a report file into the project, it becomes a ‘strongly-typed’ report. In this case, you will have the advantage of directly creating an instance of the report object, which could reduce a few lines of code, and caching it to improve performance. The related .vb file, which is hidden, can be viewed using the editor’s ‘show all files’ icon in the Solution Explorer.Â

- Un-Typed Report :

Those reports that are not included into the project are ‘un-typed’ reports. In this case, you will have to create an instance of the Crystal Report Engine’s 'ReportDocument' object and manually load the report into it.



---- Other things you should know ----

- Though the Crystal Report Viewer control comes with some cool in-built options like zooming, page navigation, etc., it does not have a custom print option. You will have to depend on the browser’s print feature.

- An un-registered copy of will remain active only for the first 30 uses, after which the ‘save’ option will be disabled. To avoid this, all you have to do is register the product with www.crystaldecisions.com for which you are not charged.

- The default installation will service only 5 concurrent users. To support more users, you will have to buy additional licenses from www.crystalDecisions.com





GETTING A FEEL OF IT – USING AN EXISTING CRYSTAL REPORT FILE IN YOUR .aspx PAGE



Lets take a look at how we could get this done the fast way to get a feel of how a Crystal Report file would look like in your web form.



1) Drag and drop the "Crystal Report Viewer" from the web forms tool box on to the .aspx page
 
Old November 6th, 2004, 03:04 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Client Side JavaScript: window.Print

function PrintWindow(){
if (navigator.appName == "Microsoft Internet Explorer") {
     var PrintCommand = '< O B J E C T ID="PrintCommandObject" WIDTH=0 HEIGHT=0 ';
PrintCommand += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">';
     document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
     PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = ""; }
else { window.print();} }
 
Old November 8th, 2004, 11:42 AM
Authorized User
 
Join Date: Oct 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I should have posted earlier to this. My problem was that I was attempting use a windows form in a web application. This has been a major point of confusion for me in this project.

I overcame this problem by creating an export file into *.pdf at the same time that the report is being viewed. This export file is captured in a small frame on the web page that is the size of a dot. When I click on the print button, my code now opens the print dialog box for the adobe acrobat file, which is exactly what I was wanting.

 
Old May 11th, 2008, 10:34 PM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I am actually looking for what you are doing. I've manage to export my report to *.pdf by prompting user to open,save or cancel. How do you capture to small frame on web page and open the print dialog box for the adobe acrobat file? Can you assist me on that? Thanks!


Quote:
quote:Originally posted by toekneel
 I should have posted earlier to this. My problem was that I was attempting use a windows form in a web application. This has been a major point of confusion for me in this project.

I overcame this problem by creating an export file into *.pdf at the same time that the report is being viewed. This export file is captured in a small frame on the web page that is the size of a dot. When I click on the print button, my code now opens the print dialog box for the adobe acrobat file, which is exactly what I was wanting.






Similar Threads
Thread Thread Starter Forum Replies Last Post
PrintReport() Problem ...Plz Help chansimone Crystal Reports 1 December 1st, 2004 04:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.