SAP Knowledge Base Article - Public

1619352 - Number formatting not retained when exporting a report to MS Excel format, from Crystal Reports

Symptom

  • Thousands separator character, and decimal character different in MS Excel
  • Report export to MS Excel format does not retain the format for decimals and thousand separators
  • Format specified for a numeric value in Crystal Reports for the thousand separator and decimal character is different when exported to MS Excel

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Reproducing the Issue

  1. In Crystal Reports designer, create a report off any data source that contains numeric database fields.
       
  2. Format the numeric field to display a space for thousand separator
    • Right click on the numeric database field and select "Format Fields..."
    • In the Format Editor window, under the tab: Number, click on the button: Customize
    • In the Custom Style window, set the formatting option: Thousand Separator Symbol to a space ( )
       
  3. Format the numeric field to display a comma for decimals
    • Still in the Custom Style window, set the formatting option: Decimal Separator to a comma (,)
    • Click OK to accept the change
    • Click OK again to accept the change
       
  4. Export the report to MS Excel format
      
  5. Open the document in MS Excel, and notice the thousand separator is a comma, and the decimals is a dot instead of a space and a comma.

Cause

  • MS Excel does not have all of the numerical formatting option Crystal Reports has. There is no option to change the character used for decimals and thousand separator for a cell in MS Excel, and this is why when exporting a report to MS Excel format, those options are not retained.
       
  • In MS Excel the decimals and thousands separator format is based on the regional setting set in MS Windows.

Resolution

  • As a workaround to retain the format of your numeric value when exporting to MS Excel, you can convert your number to text using the function: ToText
  1. Create a formula using the ToText function to convert the number into string, into the desired format, the formula will look like:

ToText({Numerical Database Field},2," ",",")

Where the arguments for the ToText functions are: 
 
- x is a Number or Currency value to be converted into a text string; it can be a whole or fractional value.
- y is a whole number indicating the number of decimal places to carry the value in x to (This argument is optional.).
- z is a single character text string indicating the character to be used to separate thousands in x. Default is the character specified in your International or Regional settings control panel. (This argument is optional.)
- w is a single character text string indicating the character to be used as a decimal separator in x. Default is the character specified in your International or Regional settings control panel. (This argument is optional.)

  1. Insert the formula on the report.
     
  2. Export the report to MS Excel.

Keywords

MS Excel, CR, Crystal Reports, export, Decimals, Thousand separators , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , Problem

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016 ; SAP Crystal Reports XI R2