Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
0
down vote
favorite
I'm trying to export the crystal report to Excel with HEADERS. When i use ExportFormatType.ExcelRecord we only get Data but not the headers(here we get .xls format). I know that ExportFormatType.Excel option will export with Headers but its in .CSV format with blanks and all which is of no use for the client to process the data further.

So wanted to know if there is any way to achieve this requirement where the formatting is good with HEADERS and process the data further.

Thanks.


What I have tried:

i have tried using
ExportFormatType.Excel
but it gives a csv file with the entire report like footer,report header etc.Tried formatting the report to my best to avoid blank spaces.But still get blank spaces in the Excel csv file.
Posted
Updated 21-Sep-17 10:21am

1 solution

Try this solution (From MSDN)

// Declare variables and get the export options.
ExportOptions exportOpts = new ExportOptions();
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions ();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = Report.ExportOptions;

// Set the excel format options.
excelFormatOpts.ExcelUseConstantColumnWidth = true;
excelFormatOpts.ExcelTabHasColumnHeadings = true;
exportOpts.ExportFormatType = ExportFormatType.Excel;
exportOpts.FormatOptions = excelFormatOpts;

// Set the disk file options and export.
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
diskOpts.DiskFileName = fileName;
exportOpts.DestinationOptions = diskOpts;

Report.Export ();


Pay special attention to the line:
excelFormatOpts.ExcelTabHasColumnHeadings = true;
 
Share this answer
 
Comments
Prathap Gangireddy 22-Sep-17 1:30am    
Thank a lot...finally my search ends.Now I'm able to process the data in excel like filtering.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900