Excel formatting issues when using Crystal Reports SDK for VS .NET
We are using Crystal Reports SDK for VS .NET in our windows application development in VS2010 .net. The Crystal Report Viewer is embeded in the WinForm and tied up to the ReportDocument to display the Crystal Report developed in Crstal Report 2011.
The Export button in the Crystal Report Viewer , which is part of the Crystal Reports SDK for VS .NET doesn’t give us the options to select “show gridlines” as in CR XI and to open the exported Export Report in Excel (Application option missing) .The only option is to store to a Disk file location and the Excel file stored doesn’t show grid lines.
So we started using the CrystalReports.Engine Api(s) with ExcelFormatOptions, and passed it as parameter to the ReportDocument.Export method.
When we do that we are getting formatting issues. the format of the Excel output is not matching the format of the Orginal Report in CR2011(i.e when it is exported using the Crystal Designer IDE)
Please suggest ideas to match the formats as our users are using the Excel outputs to feed other systems and hence the formatting becomes atmost importance for us to use Crystal Reports. I give below the code we use to achieve this so far
strRepFileName = Report_ID.Trim() + “.xls”;
dfDestinationOptions.DiskFileName = strRepFileName.Trim();
exOptions.ExportDestinationType = ExportDestinationType.DiskFile;
exOptions.DestinationOptions = dfDestinationOptions;
ExcelFormatOptions exopt = new ExcelFormatOptions();
exopt.ShowGridLines = true;
exopt.ConvertDateValuesToString = true;
exopt.ExcelAreaGroupNumber = 1;
exopt.ExcelAreaType = AreaSectionKind.Detail;
exopt.ExcelTabHasColumnHeadings = true;
exopt.ExcelUseConstantColumnWidth = true;
exopt.ExportPageBreaksForEachPage = true;
exopt.ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage;
exopt.UsePageRange = true;
ExportOptions exOptions = new ExportOptions();
exOptions.ExportFormatType = ExportFormatType.Excel;
exOptions.ExportFormatOptions = exopt;