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:
- right click on the field
- select "Size and Position..."
- Change the Width field to a value greater than the printers paper width
- Export the report to Microsoft Excel (97-2003)
- 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:
- right click on the field
- select "Size and Position..."
- Change the Width field to a value less than the printers paper width
- Export the report to Microsoft Excel (97-2003)
- 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