Monday, July 24, 2006

Crystal Reports

In two previous posts we saw examples from "academic" world: .DJVU and .PS files. Now let's take a look at an example from "business" world. Here is a quote from wikipedia:
Crystal Reports is a Business Intelligence application used to design and generate reports from a wide range of data sources. Several other applications, such as Microsoft Visual Studio, bundle an OEM version of Crystal Reports as a general purpose reporting tool.
BTW, there also exists "Crystal Reports for Delphi 2005".

We can download Crystal Reports XI trial (or Crystal Reports XI Release 2 with support for Visual Studio 2005) from "Business Objects" website. We also need a database - DBF (dBase) file is the simplest Here is one inside ZIP file (language classification table by Dr. Stephen Huffman).

Before we start building report let's stop Microsoft Windows Print Spooler (since doknir is its replacement). This can be done in several ways:
  1. Enter command net stop spooler in Windows Command Prompt (cmd).
  2. Start "Control Panel"->"Administrative Tools"->"Services". Double click on line "Print Spooler" and click on button "Stop".
  3. Same as 2.) but you can open "Services" tool using Start->Run dialog by entering command: services.msc
We can verify that print spooler is not running by trying to "Add Printer" - the following message should appear: "Operation could not be completed. The print spooler service is not running".

Now, start Crystal Reports (I use version 10) to create new report based on DBF file (BTW, I tried to open existing report and the following message appeared: "Invalid Printer: The default printer is not valid. Printing will be disabled.". Obviously, Crystal Reports was confused because windows print spooler was not running. Well, thanks to doknir, we will be able to print report :)

Anyhow, click on "New" in menu "File" to start report creation wizard. The most important thing is to choose the data file. To do this, click '+' in front of "Create New Connection" and then click again on '+' in front of 'xBase'. Select 'lang_family.dbf':

Continue with report creation by clicking on 'Next'.

Let's take a look at "Printer Setup" in File menu. As we can see "No Printer" is checked and disabled. Default "Paper Size" is Letter and if we click on combobox, there are only five choices: A4, A5, B5, Legal and Letter:

There is no custom paper size!!! It is sad that after so many years "Crystal Reports" are still based on printer drivers. I hope that it will be possible to define custom page size in version XII.
For example, Microsoft Word does not depend on windows printer subsystem since version Word 97, according to this article (KB 166016):
Use printer metrics
to lay out document

If this option is
enabled, Word will
use the information from the printer
driver that is installed as in some
earlier versions of Word.

If this option is
disabled (default),
Word will use build-in metrics to lay
out the document. This means your
document will look the same no matter
what printer driver is installed.
Here are some additional arguments why it is not good to rely on printer drivers.

Back to Crystal Reports - how to print our new report? Fortunately it is possible to export report to PDF file by clicking on "Export..." in "File" menu:

Open folder where new PDF report is saved, right-click on PDF file and choose 'doknir' to "print" it in virtual appliance - it will appear inside KGhostView window. For example, I printed and scanned first page and bellow is the result:

Can this process be simpler? Of course ... [in work]

P.S. For more information about Crystal Reports, read "Underground News" by Ken Hamady or read free chapters of new book by Brian Bischof.


No comments: