Just Arrived: Crystal Reports Encyclopedia Vol 2

Congrats to Brian Bischof for publishing Crystal Reports Encyclopedia for .NET 2005 and 2008, and the redesign of the companion site at http://www.crystalreportsbook.com/.

In the past, I can’t say enough how helpful Brian’s books have been.  These are the manuals Crystal Seagate Business Objects SAP should send out with the software.  Brian’s books are very readable, very easy to follow, and have examples in both C# and VB.NET.

If you’re doing any work at all with Crystal Reports, you owe it to yourself to get the corresponding book and get to work.

DotNetKicks Image

Multiple Excel Spreadsheets and Crystal Reports

From the mailbag, in response to Exporting to Excel in Crystal Reports .NET – Perfect Excel Exports

Hi, I was searching in the internet about how to solve a problem I have and found your name in an asp alliance article, I left a post there but I prefer to email you.
The problem is this:
Im developing a project with VS 2005 and Crystal Reports, I need to export two reports to Excel but not in just two different xls files but just one with different sheets, if you know how to help me please

Crystal Reports isn’t designed for this.  If you want to easily create Excel from data, you need to look into a product like Spreadsheet Gear, OfficeWriter or ActiveXLS.  I’ve used the free ExcelXmlWriter with great success.

Handling Large Data Sets in ASP.NET and Crystal Reports

I receive a lot of feedback from my ASP Alliance articles, usually comments.  I don’t typically answer via e-mail, since that doesn’t help the community.  Today I received the following message, and felt it was blog worthy.

Referring URL: http://aspalliance.com/532
Dear Rechard,

I have always been using Datasets and they have given me consistent Results. In fact, I DO NOT USE Report Viewer but export CR Report to a PDF File and then give it to the user as a URL.

BUT, WHEN DATA IS VERY LARGE, THE DATASETS GIVE PROBLEMS such as out of Memory, server not available, Timeouts, hanging etc. I have asked this question to many forums as to how to handle large data sets in ASP.Net with CR.Net. But, nobody has given me any satisfying answer.

I really want to know as to how to solve this problem.

Will You please Help Me.

With Warm Regards,

DN

Here’s the problem–the amount of memory which can be utilized by an ASP.NET web app is 2GB (3GB if you use the /3GB switch).  If your dataset exceeds 2GB on a Windows 2003 Server, you will get a Server Not Available error.  Less than but close to 2GB will cause a significant decrease in performance or warnings about memory.

The answer is simple–you need a smaller dataset!  A 2GB dataset is far too large, especially when you’re feeding it into Crystal Reports.  It sounds like you are dumping every bit of raw data into the report, and having the report process and present the data.  You really need to have your database queries doing more of the filtering and processing, then return a significantly smaller dataset.  In a web environment, it’s best if you only do presentation in your reports–leave the calculations and filtering to the database.

Crystal Reports .NET: Setting Paper Orientation Programmatically

This is a question I see very often, and you can set the paper orientation in code-behind as such:

ReportDocument.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape

Crystal Reports .NET Programming
If you’re new to Crystal Reports, or just to CR .NET, this is the book you need. Part how-to, part programming reference, lots of simple examples in both C# and VB.NET.

 

Now playing: RentOut Tonight

Crystal Reports Pop-ups and XP SP2

If you haven’t read the article “CodeSnip: Opening Crystal Reports in a New Window in ASP.NET” (http://aspalliance.com/525), do that before you read this.  I received this comment recently:


When I tried this, it was blocked by Windows XP SP2. When I said to temporary allow blocked items, it stated it had to refresh, and then nothing happen.  I got the original page back, not the new page containing the report.

Any suggestions.


My first suggestion is to make sure there are no other pop-up blockers installed and running.  Many antivirus programs install pop-up blockers (sometimes called “ad blockers”), and every search engine toolbar I know of also includes a pop-up blocker.  I use this codesnip in an application I wrote and support; on one support call, we found four pop-up blockers installed (XP SP2, McAfee, Google and Yahoo toolbars).

I also suggest permanently allowing pop-ups from the site you’re working on–add your site to the “allowed sites” list (Tools >> Popup Blocker>> Popup Blocker Settings, then enter the URL of your site).  This will always allow pop-ups from the site in question, and will make debugging easier.

If you are exporting to PDF, XLS, etc. in this window, there are a couple of other settings you may need to adjust.  Go to Tools >> Internet Options >>Security, and choose the zone your website is in (Internet or Local Intranet), and click “Custom Level”.  Scroll down about 1/3 of the way, to the Downloads section, and Enable both “Automatic prompting for file downloads” and “File download”.  In my case, I’ve had to adjust these settings for both zones, since I develop and test in Local Intranet, but deploy to Internet.

I have yet to have a problem after doing all of these things.  You may need to close and restart IE to get all the settings to take effect.


 


Now playing: Marc BroussardHome

Crystal Reports .NET Error – “The request could not be submitted for background processing.”

There are several causes for this message, you should read all the information before trying any one of these solutions.


1) This is a known issue in some versions of Crystal Reports, and there is a hot fix at http://support.businessobjects.com/library/kbase/articles/c2012318.asp.


Note that although the article’s metadata indicate this hotfix is for CR .NET, the body copy speaks only of CR 9.0.  As such, apply this hotfix with some trepidation.  On Win XP systems, you may want to make a retore point in case the hotfix messes up your installation.


2) On a Win 98 machine, exporting to HTML 3.2 or 4.0.  There is no known fix at this time.  http://support.businessobjects.com/library/kbase/articles/c2013300.asp


This error message seems to stem from problems in crqe.dll, which is the Crystal Reports Query Engine.  If you search the knowledgebase at support.businessonjects.com for crqe.dll, you’ll find additional articles that aren’t specific to this error message that may also help/


Crystal Reports .NET Programming
If you’re new to Crystal Reports, or just to CR .NET, this is the book you need. Part how-to, part programming reference, lots of simple examples in both C# and VB.NET.


 


 


 


Windows XP SP2 Users Can’t Open Crystal Reports Exported To PDF or Excel

I have a web forms application based on Crystal Reports .NET 2003, and one of the options I present users is the choice between HTML output (using CrystalReportViewer), or export to PDF or XLS.  All the reports from this application open in a new window (see http://aspalliance.com/525), which adds an additional problem with Win XP SP2.  Usually, setting the pop-up blocker to “always allow pop-ups from this site” fixes the problem, but not in this recent case. 


In this recent case, the popup window opened normally, and HTML output worked fine.  For PDf and XLS output, the popup would open and close in an instant, with no prompt to download the file.  We eventually figured out that prompting for file downloads, and downloads themselves, can be disabled with IE6 and XP SP2.  Previous versions of IE allowed you to disable downloads, but the prompt disable was new to me.


Long story short, if your users aren’t being prompted to download the output file, change the IE settings by navigationg Tools >> Internet Options >> Security >> Custom Level, and make sure “Automatic promting for file downloads” and “file download” are both enabled.

Lose Your Crystal Reports .NET Field Explorer?

That window in the Crystal Reports .NET designer that shows the database fields, formula fields, etc. is called the “Field Explorer”, unless you need to reopen it.  If you need to reopen the Field Explorer, navigate View >> Other Windows >> Document Outline.  In the CR Designer, the Document Outline becomes the Field Explorer.  On other pages, it’s just the Document Outline.

“How do you know how big to make a field in Crystal Reports?”

Laying out a Crystal Report can be stressful, especially when you’re guessing at how wide to make a field so string data fits.  The problem is, string database fields (such as nvarchar) are measured in characters, but text felds are measured in inches or centimeters.  You could guess at the field width, run the report, see if everything fits, and keep adjusting and running until the entire database field fits the field on your report.


Or you can be smart.


Open your database (or database schema, whatever you are using), and see the maximum length of the data field.  Let’s say we have a varchar(50).  We know the maximum number of characters is 50.  On your report, add a Text Object, and make it kind of wide.  Type in 50 M’s (like this: MMMMMMMMMM…).  Resize the text object until all the M’s are visible.  Drag the database field onto your report, and make it the same width as the 50 M text object.  That is the maximum width your database field will be.


In proportional fonts (such as Times New Roman or Verdana), the uppercase M is typically the widest letter (in monospaced fonts like Courier New, all the letters are the same width).  Using the letter M is an old typesetter trick, and carries over into today’s world.  If you have ever used CSS, and set a font size to ‘1 em’, the ’em’ unit is equivalent to the width of the M in that font face (this is different than the <EM> tag, which italicizes the text).  The ’em’ unit does not have a definite width (such as a cm or in), but is a relative width in each font based on that font’s specification.