1886099 - Export to Excel fails if any field width is greater than the Printers paper width

SAP Knowledge Base Article - Public

1886099 - Export to Excel fails if any field width is greater than the Printers paper width

Symptom

In a .NET application or with Crystal Reports Designer and exporting to Microsoft Excel (97-2003) if the field objects Width is set to a size greater than the Printers paper width CR Designer will generate and error: Failed to Export the report followed by another message: Not Supported.

Note: Error message may vary depending on the data within the field. In this case there were file paths and URL's.

Environment

  • Crystal Reports 2008 V1
  • Crystal Reports 2011
  • Crystal Reports Developer for Visual Studio ( 2010/2012 )

Reproducing the Issue

Set any fields width to a size greater than the printers page width:

  1. right click on the field
  2. select "Size and Position..."
  3. Change the Width field to a value greater than the printers paper width
  4. Export the report to Microsoft Excel (97-2003)
  5. Click OK and the error will  be generated

In a .NET SDK application use the following code:

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt1 = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ISCDReportClientDocument rcd;

rpt1.ReportClientDocument.LocaleID = CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishCanada;
rpt1.Load(@"C:\Reports\test.rpt");

rcd = rpt1.ReportClientDocument;

CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatMSExcel;
exportOpts1.FormatOptions = excelOpts;

rcd.PrintOutputController.ExportEx(exportOpts1).Save(@"C:\Reports\test.xls", true);
MessageBox.Show("Export to Excel Completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

rpt1.Close();
rpt1.Dispose();

Resolution

Set the fields width to a size equal to or less than the printers page width:

  1. right click on the field
  2. select "Size and Position..."
  3. Change the Width field to a value less than the printers paper width
  4. Export the report to Microsoft Excel (97-2003)
  5. Click OK

In a .NET application and adding a field make sure the width is less than printer paper width.

You can either do this manually or query the local printer info to get the printers paper width value.

Also Note using exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatRecordToMSExcel

does not have this issue. Only when generating page oriented formatting.

Keywords

KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports, developer version for Microsoft Visual Studio