SAP Knowledge Base Article - Public

2691102 - Conversion of Country setting (Locale) when exporting to RTF format changes to local setting and not the default "C" value

Symptom

We have the following problem:

  • In the Crystal Reports Viewer 13 after Export the report to RTF/Word (with the export-icon) the Locale is changed from "C" to "German_Germany.1252".
  • This behavior when exporting to RTF/Word always occurs.  
  • Description: Call from a C ++ / C program with Locale = "C": By calling the Crystal Reports method (C # code via COM interface) "m_ReportDocument.Export (oExportOptions);" the locale is suddenly set from "C" to "Germany - German - 1252"  

Information: When exporting to Excel (XLS), the conversion does not occur.

Environment

Crystal Reports Developer for Visual Studio - Service Pack 23: V.13.0.23.2819

Resolution

The following sample code does not cause this to happen:

// ExportRpt.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include "locale.h"
using namespace System;
using namespace System::IO;
using namespace CrystalDecisions::Shared;
using namespace CrystalDecisions::CrystalReports::Engine;

int main()
{
CrystalDecisions::CrystalReports::Engine::ReportDocument^ m_ReportDocument = gcnew CrystalDecisions::CrystalReports::Engine::ReportDocument();
String^ sampleReportPath = gcnew String("c:/reports/World Sales Report.rpt");
struct lconv * lc;
try
{
lc = localeconv ();
m_ReportDocument->Load(sampleReportPath);
String^ outpath = "C:/temp/World Sales Report.rtf";
if (File::Exists(outpath))
{
File::Delete(outpath);
}

CrystalDecisions::Shared::ExportOptions^ expOpts=gcnew CrystalDecisions::Shared::ExportOptions();
CrystalDecisions::Shared::PdfRtfWordFormatOptions^ expFmtOpts= gcnew CrystalDecisions::Shared::PdfRtfWordFormatOptions();
CrystalDecisions::Shared::DiskFileDestinationOptions^ dfDestinationOptions = gcnew CrystalDecisions::Shared::DiskFileDestinationOptions();

dfDestinationOptions->DiskFileName=outpath;
expFmtOpts->FirstPageNumber = 1;
expFmtOpts->LastPageNumber = 1;
expOpts->ExportDestinationType = ExportDestinationType::DiskFile;
expOpts->ExportDestinationOptions = dfDestinationOptions;
expOpts->ExportFormatType = ExportFormatType::RichText;
expOpts->ExportFormatOptions = expFmtOpts;
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);
m_ReportDocument->Export(expOpts);
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);

}
catch (Exception^ ex)
{
Console::WriteLine("ERROR: " + ex->Message);
}

}

Keywords

cr for vs, export to rtf, locale , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio