View Single Post
  #2 (permalink)  
Old October 4th, 2007, 01:00 AM
waseemraza1978 waseemraza1978 is offline
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Shakti,

Hope u are doing fine.
I tried your code but it gives me the following error:
Server Error in '/Ultrabot7' Application.
--------------------------------------------------------------------------------

Method 'ISCREditableRTFExportFormatOptions_reserved5' on type 'CrystalDecisions.ReportAppServer.ReportDefModel.E ditableRTFExportFormatOptionsClass' from assembly 'CrystalDecisions.ReportAppServer.ReportDefModel, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' is overriding a method that has been overridden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Method 'ISCREditableRTFExportFormatOptions_reserved5' on type 'CrystalDecisions.ReportAppServer.ReportDefModel.E ditableRTFExportFormatOptionsClass' from assembly 'CrystalDecisions.ReportAppServer.ReportDefModel, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' is overriding a method that has been overridden.

Source Error:


Line 57: ex.ExportDestinationOptions = destinationURL;
Line 58: ex.ExportFormatOptions = formatOptionEXCEL;
Line 59: mainReportDocument.Export(ex);
Line 60:
Line 61: }

.......

here is my code:
[[[[[[[[[[[[[[[[
mainReportPath = "../Reporting/Templates/UsersExportList.rpt";
                    mainReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
                    mainReportDocument.Load(Server.MapPath(mainReportP ath));


                    ExportOptions ex = new ExportOptions();
                    DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
                    ExcelFormatOptions formatOptionEXCEL = new ExcelFormatOptions();
                    destinationURL.DiskFileName = "..//report.xls";
                    ex.ExportDestinationType = ExportDestinationType.DiskFile;
                    ex.ExportFormatType = ExportFormatType.Excel;
                    ex.ExportDestinationOptions = destinationURL;
                    ex.ExportFormatOptions = formatOptionEXCEL;
                    mainReportDocument.Export(ex);

]]]]]]]]]]]]]]]]]]]]]]

please help me where i am wrong.
Best Regards
Waseem

Quote:
quote:Originally posted by shakti_2505270
 hi,
This is Shakti. I work as a Software Programmer.
I have seen that most of young programmers search for code to Export a Crystal Report to different Formats. So here their search comes to an end.



ReportDocument rd = new ReportDocument();
rd.SetDataSource(dt);
// Here i have considered that rd has been set with DataTable dt as its SetDataSource property.
// Hence forth the code to Export the Crystal Report to other formats starts.

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
ExcelFormatOptions formatOptionEXCEL = new ExcelFormatOptions();
destinationURL.DiskFileName = "..//report.xls";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.Excel;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionEXCEL;
rd.Export(ex);

//The above code exports the Crystal Report to Excel
//Similarly you can export Crystal Reports to PDF

ExportOptions ex = new ExportOptions();
DiskFileDestinationOptions destinationURL = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions formatOptionPDF = new PdfRtfWordFormatOptions();
destinationURL.DiskFileName = "..//report.pdf";
ex.ExportDestinationType = ExportDestinationType.DiskFile;
ex.ExportFormatType = ExportFormatType.PortableDocFormat;
ex.ExportDestinationOptions = destinationURL;
ex.ExportFormatOptions = formatOptionPDF;
rd.Export(ex);