Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

15.06 HTML Options

Set the HTML version you want to export to by selecting the menu options File > Export > Export Report. After making your selection you are presented with the HTML export options dialog box shown in Figure 15-3.



Figure 15-3. HTML export options.

The first option is to set where you would want to save the HTML file. This works a little differently than the typical Save As dialog box that you are familiar with. Rather than specifying an existing directory you want to save the file in, you specify a new directory you want created. When you click the OK button it creates the new directory and saves the files to it. If you enter a directory name that already exists, then it can potentially overwrite any existing files with the same file names.

The two input areas below the directory name let you choose the drive and location where the new directory should be created.

When setting where the file should be stored, if you have access to the web server via the network, you can have Crystal Reports export directly to the web server. This typically isn’t the best idea because you always want to test report output prior to putting it on the production server. I suggest that you first save it to your local hard drive and testing it with different web browsers installed on your computer. Once you feel that the report is ready, you can copy it to the web server for public use.

On the right side of the dialog box is where you specify the file properties. The Base File Name input box is where you type in the name that you want the HTML file exported as. Below that you can specify if you want to use page navigation links and whether you want the HTML page to be broken up into multiple pages. Let’s look at these two options in more detail.

The Page Navigator option lets you have four navigational hyperlinks at the bottom of each page: First Page, Previous Page, Next Page and Last Page. This is shown in Figure 15-4.



Figure 15-4. HTML page navigation.

The user clicks on the hyperlinks to navigate between the different pages. Notice that there isn’t a way to jump to a specific page elsewhere in the report. You can only move between consecutive pages or jump to the beginning or end of the report. However, as we’ll see in a minute, there is a trick to easily navigate to any page in the report. If you decide not to put navigational links at the bottom of each page, you will have to create your own method of allowing the user to navigate between pages in the report. One idea would be to create a Table of Contents page with each page listed as a hyperlink. When the user is finished reading the page they can click the browser’s Back button to return to the main page.

The second option lets you choose between exporting the report to a single page or to multiple pages. If you export to multiple pages, Crystal Reports takes the file name you gave it and appends consecutive numbers to it for each report page. So, if you told it to name the file ‘CustomerSales.HTML’ then the first page would be ‘CustomerSales1.HTML’, the second page would be ‘CustomerSales2.HTML’, and so on. Since the page names correspond to the page number, this makes it possible to jump to a particular page number without using the navigational links at the bottom of the page. Just enter a new page number in the browser’s address bar to jump to a specific page. Although this is easy to do, it certainly isn’t obvious and not all users will be familiar with it. You might want to mention this trick somewhere on your report.

If you export the report as a single page, then there will just be one file called ‘CustomerSales.HTML’. The benefit to the user is that all the data is on the same page and it doesn’t require any navigational links. The drawback is that if this is a very large report, then the user has to scroll up and down to read the entire report. This can be inconvenient for lengthy reports.

Although you are exporting to a single web page, Crystal Reports will not reformat the report as if it were printed on one page. Instead, the individual report pages are printed on one large web page. Let’s see how this is different from changing a report’s paper size and sending it to the printer. Consider that you print a report using a paper size of 8 ½ x 11 and it prints 40 records on each page. You then change the paper size to be 8 ½ x 14 in landscape mode and now it prints 60 records on each page. By making the paper size longer, Crystal Reports reformatted the report to take advantage of the extra space. Exporting to HTML doesn’t work this way.

When exporting to a single HTML page, Crystal Reports doesn’t consider the HTML page to be one long page and format it so that all the records appear on a single continuous page. Instead, it effectively takes a snapshot of each of the pages in the report and shows them consecutively one after the other. You can almost think of them as ‘virtual pages’. It even repeates the page header and page footer over and over. If you have the Page Navigator option turned on, there will be hyperlinks after each page footer that jump to the next ‘virtual page’. Of course, there are times when you want this (e.g. printing invoices) and there are times when you would rather have all the rows printed consecutively without showing page breaks. Regardless, this is the way it works and you should be aware of it so that you know what to expect.

After setting the file name and determining how to handle page navigation and multiple pages, the last option is setting the page range. Below that is an informational area where Crystal Reports gives you some notes to help clarify what the options do. Click the OK button to export the file and test it in your browser.