SAP Knowledge Base Article - Public

1673125 - Special field Page N of M is incorrect when exported to CSV and TXT file formats

Symptom

  • Exporting a report from Visual Studio 2010 application to CSV and / or TXT file formats
  • Report contains the special field "Page N of M"
  • Export of one page report is correct showing "Page 1 of 1"
  • Export of multi-page report shows the field as "-1 to 1" on all pages

Environment

  • Crystal Reports for Visual Studio 2010
  • Visual Studio 2010

Reproducing the Issue

  1. Create a multi-page report.
  2. Place the special filed "Page N of M" in the footer of the report.
  3. Create a VS .NET application using the following code:
Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
        crReportDocument.Load("C:\test\test.rpt")
        crReportDocument.ExportToDisk(ExportFormatType.Text, "c:\crystal\formulas.txt")
        crReportDocument.ExportToDisk(ExportFormatType.CharacterSeparatedValues, "c:\crystal\formulas.csv")
       
End Sub

Cause

The issue has been identified and tracked under ID ADAPT01608831.

Resolution

  • Possible work-around: use the Special Filed "Page Number"
  • InProc RAS SDK C++ code that will insert the "Page Number" field at runtime:
CrystalDecisions::ReportAppServer::ClientDoc::ISCDReportClientDocument ^reportClientDocument = thisReport->ReportClientDocument;
  for each (CrystalDecisions::ReportAppServer::ReportDefModel::Section ^boSection in
            reportClientDocument->ReportDefController->ReportDefinition->PageFooterArea->Sections) {
    for each (CrystalDecisions::ReportAppServer::ReportDefModel::ReportObject ^boReportObject in boSection->ReportObjects) {
      CString strTemp = boReportObject->Name;
      strTemp.MakeLower();
      if (strTemp.Find(_T("pagenofm")) == 0) { CrystalDecisions::ReportAppServer::DataDefModel::SpecialField ^boSpecialField = gcnew CrystalDecisions::ReportAppServer::DataDefModel::SpecialField();   // Set the type of field 
        boSpecialField->SpecialType = CrystalDecisions::ReportAppServer::DataDefModel::CrSpecialFieldTypeEnum::crSpecialFieldTypePageNumber;
 
        // Get a new field
        CrystalDecisions::ReportAppServer::ReportDefModel::FieldObject ^boFieldObject =
          gcnew CrystalDecisions::ReportAppServer::ReportDefModel::FieldObject();
        boFieldObject->DataSourceName = boSpecialField->Name;
        boFieldObject->FieldValueType = boSpecialField->Type;
 
        // Set the location of the new field to where the pageNofM was.
        boFieldObject->Left = boReportObject->Left;
        boFieldObject->Top = boReportObject->Top;
        boFieldObject->Width = boReportObject->Width;
        boFieldObject->Height = boReportObject->Height;
 
        // Add the new field to the report
        reportClientDocument->ReportDefController->ReportObjectController->Add(boFieldObject, boSection, -1);
        // Remove the pageNofM field
        reportClientDocument->ReportDefController->ReportObjectController->Remove(boReportObject);
      }
    }
  }

 

Keywords

CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 text comma coma separated value , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , Bug Filed

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio