Overview This document is intended to assist you in creating or modifying a report in the Crystal Reports Designer, Seagate Info Report Designer, or the Design tab of Seagate Analysis that exports successfully to Microsoft Excel. Contents INTRODUCTION... 2 REPORT DESIGN TIPS FOR EXPORTING TO EXCEL... 2 Background...2 Setting Report Options Before You Begin...2 Placing Objects on the Report...3 Minimizing Section Height...3 Using Guidelines to Align Fields...3 Sizing fields to have the Same Height and Width...4 Formatting Fields and Objects Consistently... 4 Examples of Good and Poor Exports...4 Example A: Good Export... 5 Example A: Poor Export... 6 SELECTING AN EXCEL EXPORTING FORMAT... 6 Supported Excel Exporting Formats...6 The Non-extended or Extended Option for Excel 8 and earlier... 7 The Data Only option for Excel 9... 7 TROUBLESHOOTING ISSUES WITH REPORTS EXPORTED TO EXCEL... 8 Blank rows appear in the Excel worksheet...8 Fields appear in different rows...9 Fields or Sections do not Conditionally Suppress Correctly...10 Blank columns appear when exporting to Excel...10 Column headers are not aligned with the data...12 Records are missing when exporting to Excel...13 Date fields appear as XXXXXXX when exporting to Excel...13 Text is truncated when exporting to Excel...14 Column and row headers in a cross-tab are not displayed...14 FINDING MORE INFORMATION... 15 CONTACTING CRYSTAL DECISIONS FOR TECHNICAL SUPPORT... 15 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 1
Introduction There are two main sections to this document. The first section contains design tips for those who have not yet started (or have just begun) to create a report for export to Excel. The second sections lists troubleshooting tips for those who have already tried exporting to Excel and were not satisfied with the results. Report Design Tips for Exporting to Excel Background Crystal Reports uses an insertion point interface. When a report is created, you are placing a series of objects on a page. These objects can be placed anywhere on the page. When the object is placed on the report, an XY coordinate is assigned to it. This XY coordinate is a measurement from the top left corner of the page. The Microsoft Excel uses a line-by-line interface. A line-by-line interface does not allow for placement of objects between the lines. Therefore, when you export a report, report objects that have been placed between lines are moved to the nearest line by the export DLL. By selecting the report options outline below, the export to Excel will maintain the column and row setup of a worksheet. We recommend that you test how a report will export by placing a few fields on the report and then exporting it to Excel. When you are satisfied with the results, continue to add the remaining fields to your report. Testing the report as it is created allows you to make the necessary design adjustments to the report fields if they are not aligned when exported to Excel. Setting Report Options Before You Begin When exporting a report from Crystal Reports (RPT) format into Microsoft Excel (XLS) format, the format may change. To minimize these changes, select the following report options. Select the report options before you begin building the report. 1. From the File menu, select Options. 2. From the Layout tab, select the following check boxes: View options Show Rulers in Design Show Rulers in Preview Show Guidelines in Design Show Guidelines in Preview 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 2
Grid options Snap to Grid Show Grid in Design Show Grid in Preview Clear Free Form Placement 3. Change the grid size (optional). The default grid size is 0.021 inches. However, we recommend that you use 0.081 inches. This makes it much easier to see individual grid points when verifying the alignment of the report objects. Placing Objects on the Report When designing a report to export to Excel, the report should appear similar to the layout of a worksheet. Do not allow the report objects to overlap. Each object should represent a cell on an Excel worksheet. Minimizing Section Height To reduce the occurrence of blank rows in the exported Excel worksheet, minimize the height of each section using the Fit Section option. Steps to Fit Section 1. In Design view, right-click the appropriate section on the gray margin to the left of the screen. 2. Click Fit Section. Fit Section resizes the section s bottom border up to the object that has been placed at the lowest point in that section. NOTE If after using Fit Section, extra space still appears below the object, resize any objects that are several lines in height. Also, verify that there are no empty text objects at the bottom of the section. Use Fit Section again to resize the section s bottom border. Using Guidelines to Align Fields How you place database fields on the report affects the layout of the Excel worksheet. Following the steps below minimize the layout differences between the original report in the Report Designer and the exported worksheet: 1. Create a guideline. To align all the fields in a row, click the vertical ruler (to the left). To align all the fields in a column, click the horizontal ruler (at the top). 2. Snap all the report objects to these guidelines. Click an object, drag it away from the guideline, and then drag it slowly back to the guideline. When the object gets close to the guideline it snaps to the line and a red mark will appear at the corner of the object. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 3
To move the object, click and drag the triangular guideline anchors on the appropriate ruler. Sizing fields to have the Same Height and Width All the fields or text objects that are to appear in the same row in Excel must be the same height in the Report Designer. Likewise, all the fields or text objects appearing in the same column in Excel must have the same width in the Report Designer. Minimizing the height of an object and space between objects reduces occurrences of blank columns and rows in the exported Excel worksheet. To set the size of an object in report design, right-click the object and select Object Size and Position. Size all the fields and text objects in the same column so they are just wide enough (and just high enough) to accommodate the tallest and longest value in the fields or text objects. Base the width of objects on the horizontal length of the data. Use the horizontal and vertical rulers as a reference when specifying height, width, and XY coordinates. Formatting Fields and Objects Consistently Format fields and objects in the same column with the same text justification, that is, right-justified, left-justified or center-justified. 1. Select all the fields and objects in a column. TIP Use the mouse to draw a lasso that selects multiple fields and objects. 2. Right-click any of the selected items, then click Format Objects. The Format Editor dialog box appears. 3. From the Common tab, select a justification in the Horizontal Alignment box. 4. Font face, style and size can also affect the width of data on the report, and consequently can affect the appearance of the exported worksheet. It is recommended to format fonts consistently. 5. In the Format Editor dialogue box, click the Font tab. 6. Select a font, style and size in the corresponding boxes for all the selected fields and objects. 7. Click OK to return to the report. Now when you preview the reports, all the fields and text objects display with a consistent format. Examples of Good and Poor Exports The following screen shots show the different results between exporting a report designed for export to Excel and one that was not. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 4
Example A: Good Export This example displays a report that has been designed with the techniques and suggestions outlined in this document and the exported result in Excel. From Crystal Reports Format To Excel Format The report format uses a grid and guidelines to align objects, and all the objects in each column have a uniform width and justification. This ensures columns are aligned and cells have the same justification in the Excel worksheet. There is minimal spacing between columns. This ensures no extra columns appear in the Excel worksheet. All objects in each row have the same height. This ensures no extra rows appear in the Excel worksheet. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 5
Example A: Poor Export This example displays a report that has not been designed with the techniques and suggestions outlined in this document and the exported result in Excel. From Crystal Reports Format To Exported Excel Format Selecting an Excel Exporting Format The report format does not use a grid and guidelines to align objects, and the objects in each column do not have the same width and justification. Therefore, columns are not aligned and cells do not have the same justification in the Excel worksheet. There is extra space between columns. Therefore, extra columns appear in the Excel worksheet. Report objects do not have the same height in each row. Therefore, extra rows appear in the Excel worksheet. Supported Excel Exporting Formats The Excel formats available depend on the version of Crystal Reports or Seagate Info Report Designer. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 6
Report Designer Version 9 8.5 With Crystal Enterprise installed (Crxf_xls.dll) 8.5 Crystal Enterprise not installed (U2fxls.dll) 8 7 6 5 Supported Export to Excel Format Excel 97 2000, Excel 97-2000 (data only) Excel 97 2000, Excel 97-2000 (data only) Excel 5 to 8 Excel 5 to 8 Excel 2.1 to 8 Excel 2.1 to 5 Excel 2.1 to 5 The Non-extended or Extended Option for Excel 8 and earlier When exporting to Excel 8, 7, 5, you may select one of two exporting options: Non-extended This format attempts to maintain as much of the report s appearance as possible. Extended This format disregards the report s appearance and places the objects in a specified column and row format. By selecting the Excel extended option, the following formatting options are available: Column headings This option places column headers at the top of each Excel column. Use worksheet functions to represent subtotal fields in report This option is for Excel to calculate subtotal values using Excel functions. This option is to export a Crystal Summary into Excel which then becomes an Excel function. For more information on worksheet functions, refer to our knowledge base article c2011861. Set column width This option either specifies a constant value for cell width, or base cell width of objects in a particular report section. Format This option allows either non-tabular or tabular format. Nontabular format arranges objects on the same horizontal coordinate into one row. Tabular format arranges all objects in one section into one row. The Data Only option for Excel 9 When exporting to Excel in version 9, you may select one of two exporting options: MS Excel 97 2000 MS Excel 97 2000 (Data Only) The Data Only option replaces the Extended option in versions previous to Excel 9. The non-data Only format (MS Excel 97-2000) produces a better WYSIWYG (What You See Is What You Get) appearance from how the report appears in the Report Designer. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 7
Troubleshooting Issues with Reports Exported to Excel This section lists common issues that are encountered when exporting to Excel format and steps to troubleshoot the issue. Blank rows appear in the Excel worksheet There are three main causes of blank rows in a worksheet. A) Fields or text objects were placed in the same section but were not horizontally aligned using guidelines or the snap-to-grid option. To prevent blank rows, use guidelines to align fields: 1. In the Design view of the report, click on the vertical ruler to create a guideline. 2. Click the field that needs to be aligned, and drag it to the guideline. The field should snap to guideline and corners should be highlighted in red, indicating that the field is attached to the guideline. 3. If the corners of the field do not turn red, repeat the above steps until the field is snapped to the guideline. 4. Set the object s size and position by right-clicking the field, selecting Object Size and Position and then setting the XY coordinates. NOTE Use the horizontal and vertical rulers as a reference when specifying height, width, and XY coordinates. Export the report to Excel and there will be no additional blank rows in the section. B) Fields of different heights were placed in the same section. To prevent blank rows, resize all the fields in the section to the same height: 1. In the Design view of the report, hold down the Shift key while clicking each field, until all the fields (and any other objects) in the section are highlighted. 2. Right-click any of the fields, click Size, and select Same Height. Export the report to Excel and there will be not additional blank rows in the section. C) Sections are formatted with complex conditional suppression formulas. To prevent blank rows from conditional suppression formulas: Do not use multiple If-Then-Else statements in conditional suppression formulas. Do not use shared variables and complex formulas that occur during the evaluation of WhilePrintingRecords (also known as 2 nd pass formulas). 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 8
NOTE WhilePrintingRecords formulas are any formulas that use a function that requires data from more than one record. Examples of these are Next, Previous, and any summary function. Such formulas can fail to evaluate during export and therefore create inconsistent results. Do not use functions that refer to page numbers, such as PageNumber, TotalPageCount, and Page N of M. References to page numbers cannot be converted when exporting to Excel. Fields appear in different rows There are three main reasons for fields to appear in a different row in Excel format than in the Report Designer. A) Fields in the same section are not vertically aligned To prevent fields from appearing in different rows, vertically align fields with guidelines: 1. In Design view, click the vertical ruler to create a horizontal guideline. 2. Click one of the fields in the section, and drag it to the horizontal guideline. The field should snap to the guideline. When the corners are highlighted in red, this indicates the field is snapped to the guideline. 3. Repeat step 2 until all the fields in the section are snapped to the horizontal guideline. Export the report to Excel and all the fields in the section appear in the same row. B) Fields in the same section do not have the same height To prevent fields from appearing in different rows, ensure that all the fields in the same section have the same height: 1. Select all the fields in the section by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, select Size, and then select Same Height. Export the report to Excel and all the fields in the section appear in the same row. C) While exporting to Excel (non-extended) allows fields from the same section to appear in more than one row To prevent the same field from appearing in more than one row, export the report to an extended Excel format. This forces all fields from one section to appear in the same row. To export to an extended Excel format: 1. From the File menu, select Print, and then select Export. 2. In the Format dialog box, select Excel Extended. 3. In the Destination dialog box, select a destination for the exported worksheet, and then click OK. The Format Options dialog box appears. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 9
4. In the Format section, click Tabular. 5. Click OK, and then specify a name and location for the exported worksheet. The next time you export this report to Excel, all the fields in the section appear in the same row. Fields or Sections do not Conditionally Suppress Correctly Complex conditional suppression formulas may not evaluate correctly during the export process and therefore can be unreliable. To minimize the chances of your conditional suppression formula failing to evaluate, follow these tips: Avoid using multiple conditional suppression formulas (that is, formulas that use multiple If-Then-Else statements). Avoid using shared variables and complex formulas that occur during the WhilePrintingRecords evaluation time. Avoid using functions that refer to page numbers, such as PageNumber, TotalPageCount, and Page N of M. References to page numbers cannot be converted when exporting to Excel. This occurs because Excel does not paginate. Instead, Excel places all the data in one large worksheet. Blank columns appear when exporting to Excel There are four main causes for extra blank columns to appear in a worksheet. A) Fields in the same column are not aligned with guidelines or snap-togrid To prevent fields from appearing in different rows, horizontally align fields with guidelines: 4. In Design view, click the vertical ruler to create a vertical guideline. 5. Click one of the fields in the section, and drag it to the vertical guideline. The field should snap to the guideline. When the corners are highlighted in red, this indicates the field is snapped to the guideline. 6. Repeat step 2 until all the fields in the section are snapped to the vertical guideline. 7. Set the object s size and position by right-clicking the field, selecting Object Size and Position and then setting the XY coordinates. Use the horizontal and vertical rulers as a reference when specifying height, width, and XY coordinates. Export the report to Excel and all the fields in the section appear in the same column. Extra blank columns will not appear. B) Objects in the same column have different widths To ensure all the objects in the same column have the same width: 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 10
1. Select all the objects (such as database fields, column header text objects, and summaries or subtotals) in the column by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, click Size, and then select Same Width. This widens all the fields in the column until they are the same width as the widest object in the column. Export the report to Excel and on extra blank columns will appear in the worksheet. NOTE Fields formatted so they are much wider than the actual size of the data can cause blank columns. Make sure the field width is just wide enough to display the longest data value. See Sizing fields to have the Same Height and Width on page 4. C) Fields and objects in the same column do not have the same text alignment For example, the column heading text object is aligned to the right, while the database field is aligned to center. To ensure all objects have the same alignment: 1. Select all the objects (such as database fields, column header text objects, and summary or subtotals) in the column by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, then click Format Objects. The Format Editor dialog box appears. 3. From the Common tab, specify an alignment in the Horizontal Alignment box. 4. Click OK to return to the report. All the objects in the same column now have the same alignment. Export the report to Excel and there will be no extra blank columns in the worksheet. D) Fields or objects with different font size and formatting (bold, italics) can cause blank columns To ensure the same font formatting for all objects in a column: 1. Select all the objects (such as database fields, column header text objects, and summary or subtotals) in the column by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, then click Format Objects. The Format Editor dialog box opens. 3. From the Font tab, specify a size and format for the object s box. 4. Click OK to return to the report. Export the report to Excel and there will be no extra blank columns in the worksheet. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 11
Column headers are not aligned with the data Column headers that are not aligned with the data in the exported worksheet are caused by the following five main reasons. A) Fields or objects in the same column are not aligned using vertical guidelines or snap to grid To prevent fields from appearing in different columns, vertically align fields with guidelines: 1. In Design view, click the horizontal ruler to create a vertical guideline. 2. Click one of the fields in the section, and drag it to the vertical guideline. The field should snap to the guideline. When the corners are highlighted in red, this indicates the field is snapped to the guideline. 3. Repeat step 2 until all the fields or objects in the section are snapped to the vertical guideline. 4. Set the object s size and position by right-clicking the field, selecting Object Size and Position and then setting the XY coordinates. Use the horizontal and vertical rulers as a reference when specifying height, width, and XY coordinates. Export the report to Excel and the column headers will align with the data. B) Fields that are not the same width are not aligned in the same column To ensure all the objects in the same column have the same width: 1. Select all the objects (such as database fields, column header text objects, and summary or subtotals) in the column by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, click Size, and select Same Width. This widens all the fields in the column until they are the same width as the widest object in the column. Export the report to Excel and the column headers will align with the data. NOTE Fields that are formatted wider than what is required to display the actual size of the data can cause blank columns. Ensure that the field width is just wide enough to display the longest data value. C) Fields appearing in the same column should have the same text alignment (right align, left align or center align) To ensure all objects have the same alignment: 1. Select all the objects (such as database fields, column header text objects, and summary or subtotals) in the column by holding down the Shift key while clicking each field, until all the fields are highlighted. 2. Right-click any of the fields, then click Format Objects. The Format Editor dialog box opens. 3. From the Common tab, specify an alignment in the Horizontal Alignment box. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 12
Export the report to Excel and the column headers will align with the data. D) Fields with different font size and formatting (bold, italics) can cause data to be unaligned To ensure uniform font formatting for all objects in a column: 1. Select all the objects (such as database fields, column header text objects, and summary or subtotals) in the column by holding down the Shift key while clicking the fields, until all the fields are highlighted. 2. Right-click any of the fields, then click Format Objects. The Format Editor dialog box opens. 3. From the Font tab, specify a size and format for the object s box. 4. Click OK to return to the report. Export the report to Excel and the column headers will align with the data. E) Non-extended Excel format can create column headers that are not correctly aligned 1. From the File menu, click Print, and select Export. 2. In the Format drop-down menu, select Excel Extended. 3. In the Destination drop-down menu, select a destination for the exported worksheet, and then click OK. The Format Options dialog box opens. 4. In the Format section, click Tabular. 5. Click OK, and then specify a name and location for the exported worksheet. Export the report to Excel and the column headers will align with the data. Records are missing when exporting to Excel When exporting a report to Excel, records are missing. Excel allows a maximum number of rows in a worksheet. If the number of records exceed Excel s maximum number or rows, then not all the records will export successfully. When exporting to Excel 7 (95) or earlier, the maximum number of rows is 16,731. When exporting to Excel 8 (97) or 9 (2000), the maximum number of rows is 64,000. Date fields appear as XXXXXXX when exporting to Excel The solution for this issue depends on which version of Excel you have exported to. In Excel version 5, Crystal Reports Date-Time fields display as XXXXXXX. To correct this, select the cells in Excel and format them as Date-Time values. In Excel versions 7.0 and 8.0, widen the column containing the affected cells. If using Office 97, install latest Service Release (SR) available from Microsoft 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 13
Text is truncated when exporting to Excel This is usually because the text is stored in a memo field. Crystal Reports exports up to a maximum of 255 characters to one cell in Excel. A cell in Excel can contain a maximum of 255 characters. Therefore, anything after the 255 th character is truncated when exported from Crystal Reports. How to Work Around Exporting a Memo Field Insert the memo field into a text object in Crystal Reports. The entire text will now export to Excel. However, the memo field will be divided into different cells. For example, if a memo field contains 500 character, then one cell in Excel would contain the first 255 characters and a second cell would contain the next 245 characters. Column and row headers in a cross-tab are not displayed Row or column header values created with the Specified Order or Customized Group Name (version 8) Group Options for cross-tabs are not displayed when the report is exported to Excel. To work around this issue, create a formula to replace the custom column headings of the cross-tab: 1. From the Insert menu, click Formula Field. 2. Click New, specify a name for the formula, and then click OK. The Formula Editor dialog box appears. 3. Enter a formula similar to the following: //@Heading //Formula to use in a cross-tab as for custom headings WhileReadingRecords; If Month({Date.Field})=1 Then Jan Else If Month({Date.Field})=2 Then Feb Else If Month({Date.Field})=3 Then Mar Else Others Use this formula for the row or column header of the cross-tab. Export the report to Excel and the column/row headers will display. 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 14
Finding More Information For more information related to exporting, refer to the following documents on our support site at http://support.crystaldecisions.com/docs: cr9_exportlimitations.pdf - Features Supported by Export Format in Crystal Reports version 9 Cr85_exportlimitations.zip - Features Supported by Export Format in Crystal Reports version 8.5 Contacting Crystal Decisions for Technical Support We recommend that you refer to the product documentation and that you visit our Technical Support web site for more resources. Self-serve Support: http://support.crystaldecisions.com/ Email Support: http://support.crystaldecisions.com/support/answers.asp Telephone Support: http://www.crystaldecisions.com/contact/support.asp 1/29/2004 4:48 PM Copyright 2002 Crystal Decisions, Inc. All Rights Reserved. Page 15