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
- Create a multi-page report.
- Place the special filed "Page N of M" in the footer of the report.
- 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);
}
}
}
- The fix for this issue was rejected as a solution would lead to a 50% peformance degradation
- For C# code see the sample application NET-CS2003_RAS-Managed_BE115_Add_Special-Field
- For more RAS SDK samples see the wiki NET RAS SDK Samples
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