Exporting to Static HTML


More and more, organizations are looking to distribute Crystal Reports to a large audience in a web format, through a company intranet or the Internet. To provide this capability, you need to convert your report to Hypertext Markup Language (HTML) format ”the markup language understood by web browsers. If you ve decided to provide only static, non-interactive reports in a web browser, you simply need to export the report from Crystal Reports, just as you d export to a Word document or an Excel spreadsheet.

Simply start Crystal Reports and open or create the report you want to export to HTML. Remember that whatever is visible on your screen is what will be exported to HTML. If you want to export the main report, make sure the Preview tab is clicked. If you want to export just a drill-down tab, select the correct drill-down tab before exporting. Then, choose File Export from the pull-down menus , or click the Export button in the Standard toolbar. Figure 21-1 shows a sample report, consisting of a report containing a title surrounded by a border on all four sides, and a drop shadow and chart placed alongside data with the underlay section formatting option.

click to expand
Figure 21-1: Sample report with special formatting features

When you choose the Export command, the resulting dialog box allows you to choose the format and destination of your report. You ll be concerned with the two HTML format options available in the Format drop-down list: HTML 3.2 and HTML 4.0. The different versions refer to the different extensions of the HTML language that Crystal Reports can use. To determine which version of HTML you want to use, experiment with your own exports and the browsers that your report viewers will use. Typically, version 4 (dynamic HTML) will better represent the actual formatting of the report in the web browser. However, older versions of a web browser (Internet Explorer or Netscape Navigator/Communicator versions prior to 4) may not be able to properly interpret DHTML. If you re using an older version of these browsers, you may see better results with HTML 3.2.

Note  

The HTML export drivers are not installed by default when you install Crystal Reports. If you see a small number 1 beside the export format (indicating install on first use ), you ll be prompted to insert the Crystal Reports program CD the first time you export to HTML.

No matter what destination you ultimately choose from the Destination drop-down list, Crystal Reports must write the HTML code and any associated graphics files (for charts , maps, and bitmaps) to a disk folder. You will be asked to make several choices about how and where you want your report exported, as illustrated in Figure 21-2.

click to expand
Figure 21-2: Export to HTML dialog box

Crystal Reports will create a whole new directory to contain the HTML and graphics files that will make up your report. The drive and folder boxes will let you choose an existing directory under which a new directory will be created. Type the name of the new directory in the Directory Name box (Crystal Reports will name the new directory HTML by default). If you wish to place the HTML in a specific folder referred to by a web home page, make sure you export to the predetermined folder on the web server referred to by the page. Crystal Reports will place the name of the report into the Base File Name box by default. You may want to change this filename to something your web server expects (for example, DEFAULT.HTM), if you are exporting to a web server folder.

You may also use the Page Navigator and Separate HTML Pages check boxes (which typically are helpful only with reports that are more than one page in length). If you check Separate HTML Pages, Crystal Reports will export sequentially numbered HTML pages, one for each page in the report. For example, if you re exporting a drill-down tab that consists of four pages, and you choose DEFAULT.HTM as the base filename, the first page of the report will be exported to DEFAULT1.HTM, the second to DEFAULT2.HTM, the third to DEFAULT3.HTM, and the fourth to DEFAULT4.HTM. If you don t check this box, all three report pages will be combined into one larger DEFAULT.HTM.

Caution  

This numbering behavior when using the page navigator may cause unintended results by appending numbers onto each HTML file. Keep this behavior in mind if your web server expects a default filename, such as DEFAULT.HTM. You may wish to actually export your report with a different filename and create a DEFAULT.HTM file that immediately redirects the viewer to the number 1 exported filename.

If you check Page Navigator, Crystal Reports will place First, Next , Previous, and Last navigation hyperlinks at the bottom of each page that is exported. If you export to separate HTML pages, these links will navigate to the proper separate HTML page. If you don t export to separate HTML pages, the navigation links will still appear inside the one large HTML page, simply moving the viewer to different locations within the one HTML page.

Once you ve specified all export options, click OK. If the folder you specified doesn t exist, Crystal Reports will automatically create it. If the folder already exists and contains an HTML file with the same name as you specified, you ll be prompted to overwrite the existing file. In addition to the HTML report file, Crystal Reports will create uniquely numbered .PNG graphics files ”one for each bitmap, chart, or map contained in the report.

When you point your browser to the folder and view the HTML file, you ll see the exported report in the browser window, as shown in Figure 21-3.

click to expand
click to expand
Figure 21-3: Export comparison between HTML 3.2 and HTML 4.0

Notice the difference between the HTML 3.2 and 4.0 exports. HTML 3.2, for example, didn t display the report title properly, and didn t include the horizontal lines between state totals. And, even though the displayed chart appeared beside text, there were significant vertical spacing issues introduced in an HTML 3.2 export. Even HTML 4.0 doesn t always perform perfect exports, but you ll often find a much better rendition of your original report formatting. It s a good idea to try sample exports as you re developing your report, to make sure you don t depend on any features that may not export properly. If your organization has standardized Adobe Acrobat format files, you can also export to .PDF in the same manner. You ll typically find that Acrobat files exhibit a very accurate representation of your original report formatting.

Note  

Remember that with HTML, particularly HTML 3.2, some fancy report formatting (such as drop shadows or special fonts) may not export to HTML properly. You ll want to try some test exports and view the resulting reports in the web browser that will be used by the majority of your report viewers. That way, you can see what your reports will ultimately look like.

Don t forget that reports exported to HTML or PDF are static. They will simply show database information as it existed when the report was exported. The only way to update the exported reports is to refresh the report in Crystal Reports and export again. Also, drilling down and using group trees won t work with exported HTML or PDF reports. If you want viewers to be able to refresh reports on their own, as well as interact with the report by drilling down and using the group tree, use other Crystal Reports web options, such as the RDC, Java Reporting Component, Visual Studio .NET, or Crystal Enterprise. And, giving web users the ability to print reports on their local printers with accurate pagination also becomes a challenge. The options that best provide this capability are PDF export, the ActiveX or Java report viewers (available with the RDC, or Crystal Enterprise), or the ActiveX print control (new in Crystal Enterprise 10).

Hyperlink Capabilities

Crystal Reports provides hyperlink capabilities so that you can build hyperlinks into your reports. Virtually any objects on your report, such as text objects, database fields, charts, maps, or bitmap objects, can be linked to web pages, e-mail addresses, other Crystal Reports, or other Windows programs. When you point to an object with an attached hyperlink, your mouse cursor turns into the now-familiar pointing finger. Click, and your web browser will launch the web site, your e-mail program will launch a new message window, or the Windows program or file that is specified will be launched.

Hyperlinks are created right in the Crystal Reports designer. In either the Design or Preview tab, select the object you want to create the hyperlink for. Then, choose Format Hyperlink from the pull-down menus, right-click, and choose Format Field (or a similar format option) from the pop-up menu, or click the Hyperlink toolbar button from the standard toolbar. The Format Editor will appear. If it s not already selected, click the Hyperlink tab, shown in Figure 21-4.

click to expand
Figure 21-4: The Format Editor Hyperlink tab

Choose the type of hyperlink you d like to create:

  • No Hyperlink If a hyperlink has already been assigned to this object, clicking this radio button will clear the hyperlink.

  • An E-Mail Address Click this radio button and add the e-mail address you want the hyperlink to send e-mail to in the Hyperlink Information text box after the mailto: text. If you d like to create a conditional string formula to customize the hyperlink according to a database field or conditional value, click the conditional formula button next to the text box.

  • A Website on the Internet Click this radio button and add the web site URL you want the hyperlink to launch in the Hyperlink Information text box after the http:// text. If you d like to create a conditional string formula to customize the hyperlink according to a database field or conditional value, click the conditional formula button next to the text box.

  • A File Click this radio button and add the path and filename of the file you want the hyperlink to launch or the command you want to execute in the Hyperlink Information text box. Type the same command or path /filename you d type after choosing Start Run in Windows. If you d like to create a conditional string formula to customize the hyperlink according to a database field or conditional value, click the conditional formula button next to the text box.

  • Current Website Field Value/Current E-mail Field Value These options are available only if you ve chosen a string database or summary field on the report. In this case, the hyperlink will simply be the value of text from the database. To correctly use this option, the database field must return a complete web site URL (including the http:// prefix), or an e-mail address, depending on which option you ve chosen .

    Note  

    The DHTML Viewer Only options in this dialog box are used to control Guided Navigation and Report Part viewing. More details can be found later in this chapter under Navigating and Viewing Report Parts.

To further benefit the report viewer, you may wish to click the Common tab on the Format Editor and add a tool tip indicating what the hyperlink does. Either type the tool tip into the tool tip text box directly, or click the conditional formula button next to the text box and enter a string formula that will display when the viewer moves his or her mouse over the object.

Once you ve specified all necessary information, click OK to close the Format Editor. When you preview the report in Crystal Reports, you ll see the mouse cursor change to a familiar pointing finger hyperlink cursor when you point to the object. If you added a tool tip, it will appear in a small yellow box. When you click your mouse button, the hyperlink will launch the web page, e-mail Send dialog box, or Windows file.

click to expand

After you create a hyperlink, follow the same steps you used to create it to modify or remove it. If you are modifying your report in the Preview tab, you may find it difficult to select an object that you ve defined a hyperlink for. If you point to it with your mouse, your mouse cursor will change to a hyperlink cursor and you ll actually execute the hyperlink if you click. If you need to select an object in the Preview tab that has a hyperlink associated with it, SHIFT-click or right-click on the object to select it.

Tip  

Hyperlinks aren t applicable only to reports exported or viewed on the Web. When you view reports in the Crystal Reports Preview tab, or view a report integrated with a custom program, hyperlinks will work as you expect. Just remember that a viewer who is using Crystal Reports needs a network connection to your corporate intranet or the Internet to successfully use web or e-mail hyperlinks.

Cascading Style Sheet Support

If you are a web developer, an option on the Format Editor Common tab may catch your eye. The CSS Class Name text box/conditional button allows you to specify a Cascading Style Sheet (CSS) class name for most any object on the report (boxes and lines are notable exceptions). By specifying a CSS class name for the object, you can control formatting globally from a style sheet in an HTML document that includes the report.

Either type a CSS class name directly into the text box, or click the conditional formula button. A conditional formula editor will appear, where you may type in a string formula that can dynamically set the CSS class name according to database fields, formula functions, and so forth.

Note  

CSS class names specified in the Format Editor will be exposed in the native HTML report viewers used with Crystal Reports integration tools and Crystal Enterprise, but not when reports are simply exported to HTML as outlined earlier in the chapter.




Crystal Reports 10
Crystal Reports 10: The Complete Reference
ISBN: B005DI80VA
EAN: N/A
Year: 2004
Pages: 223
Authors: George Peck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net