A .NET application uses Crystal Reports for Visual Studio .NET as the reporting development tool.
When you export a report to Microsoft Excel format through this application, the field headers are not aligned above the data columns. However, if the report is exported through the Crystal Reports Designer, the exported Excel file appears correctly.
When exporting a report from an application, why are the field headers not aligned in the exported Excel file? How do you resolve this issue?
This issue also occurs when exporting from a Report Designer Component (RDC) application.
When exporting from an application, the field headers are not aligned (in the exported Excel file) because the default column width is based on objects in the details section.
However, in the Report Designer, the field headers are aligned (in the exported Excel file) because the default column width is based on objects in the 'whole report'.
When exporting from an application, to base the default column width on objects in the 'whole report', use the following lines of code:
Dim excelOpts As New ExcelFormatOptions()
' Insert Applicable Options Here
crReportDocument.ExportOptions.FormatOptions = execlOpts
'Set the report to use a non-constant column width
excelOpts.ExcelUseConstantColumnWidth = False
'Set the default Width Setting for exporting to Excel as 'Whole Report'
excelOpts.ExcelAreaType = 255
XLS DOTNET VS .NET EXPORTING .XLS ALIGNMENT ALIGNING FIELD HEADERS Crystal Reports for Visual Studio Exporting Microsoft Excel Alignment , c2013305 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem